proxygen
proxygen::HTTPTransaction Class Reference

#include <HTTPTransaction.h>

Inheritance diagram for proxygen::HTTPTransaction:
folly::HHWheelTimer::Callback folly::DelayedDestructionBase proxygen::MockHTTPTransaction

Classes

struct  Chunk
 
class  PrioritySample
 
struct  PrioritySampleSummary
 
class  RateLimitCallback
 
class  Transport
 

Public Types

using Handler = HTTPTransactionHandler
 
using PushHandler = HTTPPushTransactionHandler
 
using TransportCallback = HTTPTransactionTransportCallback
 

Public Member Functions

 HTTPTransaction (TransportDirection direction, HTTPCodec::StreamID id, uint32_t seqNo, Transport &transport, HTTP2PriorityQueueBase &egressQueue, folly::HHWheelTimer *timer=nullptr, const folly::Optional< std::chrono::milliseconds > &defaultTimeout=folly::Optional< std::chrono::milliseconds >(), HTTPSessionStats *stats=nullptr, bool useFlowControl=false, uint32_t receiveInitialWindowSize=0, uint32_t sendInitialWindowSize=0, http2::PriorityUpdate=http2::DefaultPriority, folly::Optional< HTTPCodec::StreamID > assocStreamId=HTTPCodec::NoStream, folly::Optional< HTTPCodec::ExAttributes > exAttributes=HTTPCodec::NoExAttributes)
 
 ~HTTPTransaction () override
 
void reset (bool useFlowControl, uint32_t receiveInitialWindowSize, uint32_t receiveStreamWindowSize, uint32_t sendInitialWindowSize)
 
HTTPCodec::StreamID getID () const
 
uint32_t getSequenceNumber () const
 
const TransportgetTransport () const
 
TransportgetTransport ()
 
virtual void setHandler (Handler *handler)
 
const HandlergetHandler () const
 
http2::PriorityUpdate getPriority () const
 
std::tuple< uint64_t, uint64_t, double > getPrioritySummary () const
 
bool getPriorityFallback () const
 
HTTPTransactionEgressSM::State getEgressState () const
 
HTTPTransactionIngressSM::State getIngressState () const
 
bool isUpstream () const
 
bool isDownstream () const
 
void getLocalAddress (folly::SocketAddress &addr) const
 
void getPeerAddress (folly::SocketAddress &addr) const
 
const folly::SocketAddressgetLocalAddress () const noexcept
 
const folly::SocketAddressgetPeerAddress () const noexcept
 
const wangle::TransportInfogetSetupTransportInfo () const noexcept
 
void getCurrentTransportInfo (wangle::TransportInfo *tinfo) const
 
HTTPSessionStatsgetSessionStats () const
 
virtual bool extraResponseExpected () const
 
virtual void setReceiveWindow (uint32_t capacity)
 
virtual const WindowgetReceiveWindow () const
 
uint32_t getMaxDeferredSize ()
 
void onIngressHeadersComplete (std::unique_ptr< HTTPMessage > msg)
 
void onIngressBody (std::unique_ptr< folly::IOBuf > chain, uint16_t padding)
 
void onIngressChunkHeader (size_t length)
 
void onIngressChunkComplete ()
 
void onIngressTrailers (std::unique_ptr< HTTPHeaders > trailers)
 
void onIngressUpgrade (UpgradeProtocol protocol)
 
void onIngressEOM ()
 
void onError (const HTTPException &error)
 
void onGoaway (ErrorCode code)
 
void onIngressTimeout ()
 
void onIngressWindowUpdate (uint32_t amount)
 
void onIngressSetSendWindow (uint32_t newWindowSize)
 
bool onWriteReady (uint32_t maxEgress, double ratio)
 
void onEgressTimeout ()
 
void onEgressHeaderFirstByte ()
 
void onEgressBodyFirstByte ()
 
void onEgressBodyLastByte ()
 
void onEgressTrackedByte ()
 
void onEgressLastByteAck (std::chrono::milliseconds latency)
 
void setTransportCallback (TransportCallback *cb)
 
bool isIngressStarted () const
 
bool isIngressEOMQueued () const
 
bool isIngressComplete () const
 
bool isIngressEOMSeen () const
 
bool isEgressStarted () const
 
bool isEgressEOMQueued () const
 
bool isEgressComplete () const
 
bool isRemoteInitiated () const
 
bool isEgressEOMSeen () const
 
virtual bool canSendHeaders () const
 
virtual void sendHeaders (const HTTPMessage &headers)
 
virtual void sendHeadersWithEOM (const HTTPMessage &headers)
 
virtual void sendHeadersWithOptionalEOM (const HTTPMessage &headers, bool eom)
 
virtual void sendBody (std::unique_ptr< folly::IOBuf > body)
 
virtual void sendChunkHeader (size_t length)
 
virtual void sendChunkTerminator ()
 
virtual void sendTrailers (const HTTPHeaders &trailers)
 
virtual void sendEOM ()
 
virtual void sendAbort ()
 
virtual void pauseIngress ()
 
virtual void resumeIngress ()
 
bool isIngressPaused () const
 
void pauseEgress ()
 
void resumeEgress ()
 
void setEgressRateLimit (uint64_t bitsPerSecond)
 
bool isEgressPaused () const
 
bool isFlowControlPaused () const
 
bool supportsPushTransactions () const
 
virtual HTTPTransactionnewPushedTransaction (HTTPPushTransactionHandler *handler)
 
virtual HTTPTransactionnewExTransaction (HTTPTransactionHandler *handler, bool unidirectional=false)
 
bool onPushedTransaction (HTTPTransaction *txn)
 
bool onExTransaction (HTTPTransaction *txn)
 
bool isPushed () const
 
bool isExTransaction () const
 
bool isUnidirectional () const
 
void setIdleTimeout (std::chrono::milliseconds transactionTimeout)
 
bool hasIdleTimeout () const
 
std::chrono::milliseconds getIdleTimeout () const
 
folly::Optional< HTTPCodec::StreamIDgetAssocTxnId () const
 
folly::Optional< HTTPCodec::StreamIDgetControlStream () const
 
folly::Optional< HTTPCodec::ExAttributesgetExAttributes () const
 
const std::set< HTTPCodec::StreamID > & getPushedTransactions () const
 
std::set< HTTPCodec::StreamIDgetExTransactions () const
 
void removePushedTransaction (HTTPCodec::StreamID pushStreamId)
 
void removeExTransaction (HTTPCodec::StreamID exStreamId)
 
void refreshTimeout ()
 
bool testAndSetFirstByteSent ()
 
bool testAndClearActive ()
 
bool testAndSetFirstHeaderByteSent ()
 
void incrementPendingByteEvents ()
 
void decrementPendingByteEvents ()
 
void timeoutExpired () noexceptoverride
 
void describe (std::ostream &os) const
 
void updateAndSendPriority (int8_t newPriority)
 
void updateAndSendPriority (const http2::PriorityUpdate &pri)
 
void onPriorityUpdate (const http2::PriorityUpdate &priority)
 
virtual void addWaitingForReplaySafety (folly::AsyncTransport::ReplaySafetyCallback *callback)
 
virtual void removeWaitingForReplaySafety (folly::AsyncTransport::ReplaySafetyCallback *callback)
 
virtual bool needToBlockForReplaySafety () const
 
int32_t getRecvToAck () const
 
bool isPrioritySampled () const
 
void setPrioritySampled (bool sampled)
 
void updateContentionsCount (uint64_t contentions)
 
void updateRelativeWeight (double ratio)
 
void updateSessionBytesSheduled (uint64_t bytes)
 
void updateTransactionBytesSent (uint64_t bytes)
 
bool getPrioritySampleSummary (PrioritySampleSummary &summary) const
 
HPACKTableInfogetHPACKTableInfo ()
 
bool hasPendingBody () const
 
void setLastByteFlushedTrackingEnabled (bool enabled)
 
- 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::DelayedDestructionBase
virtual ~DelayedDestructionBase ()=default
 

Private Member Functions

 HTTPTransaction (const HTTPTransaction &)=delete
 
HTTPTransactionoperator= (const HTTPTransaction &)=delete
 
void onDelayedDestroy (bool delayed) override
 
void updateHandlerPauseState ()
 
void updateEgressHPACKTableInfo (HPACKTableInfo)
 
void updateIngressHPACKTableInfo (HPACKTableInfo)
 
bool mustQueueIngress () const
 
void checkCreateDeferredIngress ()
 
void sendAbort (ErrorCode statusCode)
 
void processIngressHeadersComplete (std::unique_ptr< HTTPMessage > msg)
 
void processIngressBody (std::unique_ptr< folly::IOBuf > chain, size_t len)
 
void processIngressChunkHeader (size_t length)
 
void processIngressChunkComplete ()
 
void processIngressTrailers (std::unique_ptr< HTTPHeaders > trailers)
 
void processIngressUpgrade (UpgradeProtocol protocol)
 
void processIngressEOM ()
 
void sendBodyFlowControlled (std::unique_ptr< folly::IOBuf > body=nullptr)
 
size_t sendBodyNow (std::unique_ptr< folly::IOBuf > body, size_t bodyLen, bool eom)
 
size_t sendEOMNow ()
 
void onDeltaSendWindowSize (int32_t windowDelta)
 
void notifyTransportPendingEgress ()
 
size_t sendDeferredBody (uint32_t maxEgress)
 
bool maybeDelayForRateLimit ()
 
bool isEnqueued () const
 
void dequeue ()
 
bool hasPendingEOM () const
 
bool isExpectingIngress () const
 
bool isExpectingWindowUpdate () const
 
void updateReadTimeout ()
 
void markIngressComplete ()
 
void markEgressComplete ()
 
bool validateIngressStateTransition (HTTPTransactionIngressSM::Event)
 
void flushWindowUpdate ()
 
void rateLimitTimeoutExpired ()
 

Private Attributes

RateLimitCallback rateLimitCallback_ {*this}
 
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
 
uint32_t maxDeferredIngress_ {0}
 
folly::IOBufQueue deferredEgressBody_ {folly::IOBufQueue::cacheChainLength()}
 
const TransportDirection direction_
 
HTTPCodec::StreamID id_
 
uint32_t seqNo_
 
Handlerhandler_ {nullptr}
 
Transporttransport_
 
HTTPTransactionEgressSM::State egressState_
 
HTTPTransactionIngressSM::State ingressState_
 
HTTPSessionStatsstats_ {nullptr}
 
HPACKTableInfo tableInfo_
 
Window recvWindow_
 
Window sendWindow_
 
TransportCallbacktransportCallback_ {nullptr}
 
std::unique_ptr< HTTPHeaderstrailers_
 
std::list< ChunkchunkHeaders_
 
HTTP2PriorityQueueBaseegressQueue_
 
HTTP2PriorityQueueBase::Handle queueHandle_
 
int32_t recvToAck_ {0}
 
folly::Optional< HTTPCodec::StreamIDassocStreamId_
 
folly::Optional< HTTPCodec::ExAttributesexAttributes_
 
std::set< HTTPCodec::StreamIDpushedTransactions_
 
std::set< HTTPCodec::StreamIDexTransactions_
 
http2::PriorityUpdate priority_
 
uint64_t insertDepth_ {0}
 
uint64_t currentDepth_ {0}
 
double cumulativeRatio_ {0}
 
uint64_t egressCalls_ {0}
 
uint16_t lastResponseStatus_ {0}
 
uint8_t pendingByteEvents_ {0}
 
folly::Optional< uint64_texpectedContentLengthRemaining_
 
folly::Optional< uint64_texpectedResponseLength_
 
folly::Optional< uint64_tactualResponseLength_ {0}
 
bool ingressPaused_:1
 
bool egressPaused_:1
 
bool flowControlPaused_:1
 
bool handlerEgressPaused_:1
 
bool egressRateLimited_:1
 
bool useFlowControl_:1
 
bool aborted_:1
 
bool deleting_:1
 
bool firstByteSent_:1
 
bool firstHeaderByteSent_:1
 
bool inResume_:1
 
bool inActiveSet_:1
 
bool ingressErrorSeen_:1
 
bool priorityFallback_:1
 
bool headRequest_:1
 
bool enableLastByteFlushedTracking_:1
 
uint64_t egressLimitBytesPerMs_ {0}
 
proxygen::TimePoint startRateLimit_
 
uint64_t numLimitedBytesEgressed_ {0}
 
folly::Optional< std::chrono::milliseconds > transactionTimeout_
 
folly::HHWheelTimertimer_
 
std::unique_ptr< PrioritySampleprioritySample_
 

Static Private Attributes

static uint64_t egressBufferLimit_
 

Additional Inherited Members

- Protected Member Functions inherited from folly::HHWheelTimer::Callback
virtual std::chrono::steady_clock::time_point getCurTime ()
 
- Protected Member Functions inherited from folly::DelayedDestructionBase
 DelayedDestructionBase ()
 
uint32_t getDestructorGuardCount () const
 

Detailed Description

Definition at line 324 of file HTTPTransaction.h.

Member Typedef Documentation

Constructor & Destructor Documentation

proxygen::HTTPTransaction::HTTPTransaction ( TransportDirection  direction,
HTTPCodec::StreamID  id,
uint32_t  seqNo,
Transport transport,
HTTP2PriorityQueueBase egressQueue,
folly::HHWheelTimer timer = nullptr,
const folly::Optional< std::chrono::milliseconds > &  defaultTimeout = folly::Optional<std::chrono::milliseconds>(),
HTTPSessionStats stats = nullptr,
bool  useFlowControl = false,
uint32_t  receiveInitialWindowSize = 0,
uint32_t  sendInitialWindowSize = 0,
http2::PriorityUpdate  priority = http2::DefaultPriority,
folly::Optional< HTTPCodec::StreamID assocStreamId = HTTPCodec::NoStream,
folly::Optional< HTTPCodec::ExAttributes exAttributes = HTTPCodec::NoExAttributes 
)

readBufLimit and sendWindow are only used if useFlowControl is true. Furthermore, if flow control is enabled, no guarantees can be made on the borders of the L7 chunking/data frames of the outbound messages.

priority is only used by SPDY. The -1 default makes sure that all plain HTTP transactions land up in the same queue as the control data.

Definition at line 31 of file HTTPTransaction.cpp.

References proxygen::HTTP2PriorityQueueBase::addTransaction(), assocStreamId_, currentDepth_, egressQueue_, egressState_, exAttributes_, id_, ingressState_, insertDepth_, isRemoteInitiated(), isUpstream(), priorityFallback_, queueHandle_, proxygen::HTTPSessionStats::recordTransactionOpened(), refreshTimeout(), stats_, and proxygen::http2::PriorityUpdate::streamDependency.

47  :
49  direction_(direction),
50  id_(id),
51  seqNo_(seqNo),
52  transport_(transport),
53  stats_(stats),
54  recvWindow_(receiveInitialWindowSize),
55  sendWindow_(sendInitialWindowSize),
56  egressQueue_(egressQueue),
57  assocStreamId_(assocId),
58  priority_(priority),
59  ingressPaused_(false),
60  egressPaused_(false),
61  flowControlPaused_(false),
62  handlerEgressPaused_(false),
63  egressRateLimited_(false),
64  useFlowControl_(useFlowControl),
65  aborted_(false),
66  deleting_(false),
67  firstByteSent_(false),
68  firstHeaderByteSent_(false),
69  inResume_(false),
70  inActiveSet_(true),
71  ingressErrorSeen_(false),
72  priorityFallback_(false),
73  headRequest_(false),
75  transactionTimeout_(defaultTimeout),
76  timer_(timer) {
77 
78  if (assocStreamId_) {
79  if (isUpstream()) {
80  egressState_ = HTTPTransactionEgressSM::State::SendingDone;
81  } else {
82  ingressState_ = HTTPTransactionIngressSM::State::ReceivingDone;
83  }
84  }
85 
86  if (exAttributes) {
87  exAttributes_ = exAttributes;
88  if (exAttributes_->unidirectional) {
89  if (isRemoteInitiated()) {
90  egressState_ = HTTPTransactionEgressSM::State::SendingDone;
91  } else {
92  ingressState_ = HTTPTransactionIngressSM::State::ReceivingDone;
93  }
94  }
95  }
96 
98  if (stats_) {
100  }
101 
102  queueHandle_ = egressQueue_.addTransaction(id_, priority, this, false,
103  &insertDepth_);
104  if(priority.streamDependency != 0 && insertDepth_ == 1) {
105  priorityFallback_ = true;
106  }
107 
109 }
const TransportDirection direction_
HTTPCodec::StreamID id_
folly::Optional< HTTPCodec::ExAttributes > exAttributes_
folly::Optional< HTTPCodec::StreamID > assocStreamId_
static Options cacheChainLength()
Definition: IOBufQueue.h:83
virtual void recordTransactionOpened() noexcept=0
virtual Handle addTransaction(HTTPCodec::StreamID id, http2::PriorityUpdate pri, HTTPTransaction *txn, bool permanent=false, uint64_t *depth=nullptr)=0
HTTPTransactionIngressSM::State ingressState_
http2::PriorityUpdate priority_
HTTPSessionStats * stats_
HTTPTransactionEgressSM::State egressState_
folly::HHWheelTimer * timer_
HTTP2PriorityQueueBase::Handle queueHandle_
folly::IOBufQueue deferredEgressBody_
folly::Optional< std::chrono::milliseconds > transactionTimeout_
HTTP2PriorityQueueBase & egressQueue_
proxygen::HTTPTransaction::~HTTPTransaction ( )
override

Definition at line 131 of file HTTPTransaction.cpp.

References folly::HHWheelTimer::Callback::cancelTimeout(), dequeue(), egressQueue_, isEnqueued(), folly::HHWheelTimer::Callback::isScheduled(), queueHandle_, proxygen::HTTPSessionStats::recordTransactionClosed(), proxygen::HTTP2PriorityQueueBase::removeTransaction(), and stats_.

131  {
132  // Cancel transaction timeout if still scheduled.
133  if (isScheduled()) {
134  cancelTimeout();
135  }
136 
137  if (stats_) {
139  }
140  if (isEnqueued()) {
141  dequeue();
142  }
143  // TODO: handle the case where the priority node hangs out longer than
144  // the transaction
146 }
virtual void recordTransactionClosed() noexcept=0
virtual void removeTransaction(Handle handle)=0
HTTPSessionStats * stats_
HTTP2PriorityQueueBase::Handle queueHandle_
HTTP2PriorityQueueBase & egressQueue_
proxygen::HTTPTransaction::HTTPTransaction ( const HTTPTransaction )
privatedelete

Member Function Documentation

virtual void proxygen::HTTPTransaction::addWaitingForReplaySafety ( folly::AsyncTransport::ReplaySafetyCallback callback)
inlinevirtual

Add a callback waiting for this transaction to have a transport with replay protection.

Definition at line 1176 of file HTTPTransaction.h.

References transport_.

1177  {
1179  }
virtual void addWaitingForReplaySafety(folly::AsyncTransport::ReplaySafetyCallback *callback) noexcept=0
virtual bool proxygen::HTTPTransaction::canSendHeaders ( ) const
inlinevirtual
Returns
true if we can send headers on this transaction

Here's the logic: 1) state machine says sendHeaders is OK AND 2a) this is an upstream (allows for mid-stream headers) OR 2b) this downstream has not sent a response 2c) this downstream has only sent 1xx responses

Definition at line 781 of file HTTPTransaction.h.

References proxygen::StateMachine< T >::canTransit().

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

781  {
783  egressState_,
784  HTTPTransactionEgressSM::Event::sendHeaders)
786  }
HTTPTransactionEgressSM::State egressState_
virtual bool extraResponseExpected() const
static bool canTransit(const State state, Event event)
Definition: StateMachine.h:44
void proxygen::HTTPTransaction::checkCreateDeferredIngress ( )
private

Check if deferredIngress_ points to some queue before pushing HTTPEvent to it.

Definition at line 1257 of file HTTPTransaction.cpp.

References deferredIngress_.

Referenced by onIngressBody(), onIngressChunkComplete(), onIngressChunkHeader(), onIngressEOM(), onIngressHeadersComplete(), onIngressTrailers(), and onIngressUpgrade().

1257  {
1258  if (!deferredIngress_) {
1259  deferredIngress_ = std::make_unique<std::queue<HTTPEvent>>();
1260  }
1261 }
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
void proxygen::HTTPTransaction::decrementPendingByteEvents ( )
inline

Definition at line 1142 of file HTTPTransaction.h.

1142  {
1143  DestructorGuard dg(this);
1144  CHECK_GT(pendingByteEvents_, 0);
1146  }
void proxygen::HTTPTransaction::dequeue ( )
inlineprivate

Definition at line 1284 of file HTTPTransaction.h.

Referenced by markEgressComplete(), sendDeferredBody(), and ~HTTPTransaction().

1284  {
1285  DCHECK(isEnqueued());
1287  }
HTTP2PriorityQueueBase::Handle queueHandle_
HTTP2PriorityQueueBase & egressQueue_
virtual void clearPendingEgress(Handle h)=0
void proxygen::HTTPTransaction::describe ( std::ostream &  os) const

Write a description of the transaction to a stream

Definition at line 1305 of file HTTPTransaction.cpp.

References proxygen::HTTPTransaction::Transport::describe(), id_, and transport_.

Referenced by proxygen::operator<<().

1305  {
1306  transport_.describe(os);
1307  os << ", streamID=" << id_;
1308 }
HTTPCodec::StreamID id_
virtual void describe(std::ostream &) const =0
virtual bool proxygen::HTTPTransaction::extraResponseExpected ( ) const
inlinevirtual

Check whether more response is expected. One or more 1xx status responses can be received prior to the regular response. Note: 101 is handled by the codec using a separate onUpgrade callback

Definition at line 554 of file HTTPTransaction.h.

References uint32_t.

Referenced by onIngressEOM(), and proxygen::HTTPSession::onMessageComplete().

554  {
555  return (lastResponseStatus_ >= 100 && lastResponseStatus_ < 200)
556  && lastResponseStatus_ != 101;
557  }
void proxygen::HTTPTransaction::flushWindowUpdate ( )
private

Flushes any pending window updates. This can happen from setReceiveWindow or sendHeaders depending on transaction state.

Definition at line 1335 of file HTTPTransaction.cpp.

References direction_, proxygen::DOWNSTREAM, egressState_, proxygen::Window::getCapacity(), proxygen::Window::getSize(), ingressState_, isIngressEOMSeen(), recvToAck_, recvWindow_, proxygen::HTTPTransaction::Transport::sendWindowUpdate(), transport_, and useFlowControl_.

Referenced by processIngressBody(), sendHeadersWithOptionalEOM(), and setReceiveWindow().

1335  {
1336  if (recvToAck_ > 0 && useFlowControl_ && !isIngressEOMSeen() &&
1338  egressState_ != HTTPTransactionEgressSM::State::Start ||
1339  ingressState_ != HTTPTransactionIngressSM::State::Start)) {
1340  // Down egress upstream window updates until after headers
1341  VLOG(4) << "recv_window is " << recvWindow_.getSize()
1342  << " / " << recvWindow_.getCapacity() << " after acking "
1343  << recvToAck_ << " " << *this ;
1345  recvToAck_ = 0;
1346  }
1347 }
const TransportDirection direction_
uint32_t getCapacity() const
Definition: Window.cpp:32
int32_t getSize() const
Definition: Window.cpp:23
HTTPTransactionIngressSM::State ingressState_
HTTPTransactionEgressSM::State egressState_
virtual size_t sendWindowUpdate(HTTPTransaction *txn, uint32_t bytes) noexcept=0
folly::Optional<HTTPCodec::StreamID> proxygen::HTTPTransaction::getAssocTxnId ( ) const
inline

Returns the associated transaction ID for pushed transactions, 0 otherwise

Definition at line 1048 of file HTTPTransaction.h.

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

1048  {
1049  return assocStreamId_;
1050  }
folly::Optional< HTTPCodec::StreamID > assocStreamId_
folly::Optional<HTTPCodec::StreamID> proxygen::HTTPTransaction::getControlStream ( ) const
inline

Returns the control channel transaction ID for this transaction, folly::none otherwise

Definition at line 1056 of file HTTPTransaction.h.

References proxygen::HTTPCodec::NoStream.

Referenced by onExTransaction(), proxygen::HTTPSession::onHeadersComplete(), and proxygen::HTTPDownstreamSession::setupOnHeadersComplete().

1056  {
1057  return exAttributes_ ? exAttributes_->controlStream : HTTPCodec::NoStream;
1058  }
folly::Optional< HTTPCodec::ExAttributes > exAttributes_
static const folly::Optional< StreamID > NoStream
Definition: HTTPCodec.h:51
void proxygen::HTTPTransaction::getCurrentTransportInfo ( wangle::TransportInfo tinfo) const
inline

Definition at line 541 of file HTTPTransaction.h.

References transport_.

Referenced by proxygen::RequestHandlerAdaptor::getCurrentTransportInfo().

541  {
543  }
virtual bool getCurrentTransportInfo(wangle::TransportInfo *tinfo)=0
HTTPTransactionEgressSM::State proxygen::HTTPTransaction::getEgressState ( ) const
inline

Definition at line 503 of file HTTPTransaction.h.

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

503  {
504  return egressState_;
505  }
HTTPTransactionEgressSM::State egressState_
folly::Optional<HTTPCodec::ExAttributes> proxygen::HTTPTransaction::getExAttributes ( ) const
inline

Definition at line 1064 of file HTTPTransaction.h.

1064  {
1065  return exAttributes_;
1066  }
folly::Optional< HTTPCodec::ExAttributes > exAttributes_
std::set<HTTPCodec::StreamID> proxygen::HTTPTransaction::getExTransactions ( ) const
inline

Get a set of exTransactions associated with this transaction.

Definition at line 1078 of file HTTPTransaction.h.

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

1078  {
1079  return exTransactions_;
1080  }
std::set< HTTPCodec::StreamID > exTransactions_
const Handler* proxygen::HTTPTransaction::getHandler ( ) const
inline
HPACKTableInfo & proxygen::HTTPTransaction::getHPACKTableInfo ( )

Definition at line 1249 of file HTTPTransaction.cpp.

References tableInfo_.

1249  {
1250  return tableInfo_;
1251 }
std::chrono::milliseconds proxygen::HTTPTransaction::getIdleTimeout ( ) const
inline

Returns the transaction timeout if exists. An OptionalEmptyException is raised if the timeout isn't set.

Definition at line 1041 of file HTTPTransaction.h.

1041  {
1042  return transactionTimeout_.value();
1043  }
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268
folly::Optional< std::chrono::milliseconds > transactionTimeout_
HTTPTransactionIngressSM::State proxygen::HTTPTransaction::getIngressState ( ) const
inline

Definition at line 507 of file HTTPTransaction.h.

507  {
508  return ingressState_;
509  }
HTTPTransactionIngressSM::State ingressState_
void proxygen::HTTPTransaction::getLocalAddress ( folly::SocketAddress addr) const
inline

Definition at line 519 of file HTTPTransaction.h.

References transport_.

Referenced by TEST_F().

519  {
520  addr = transport_.getLocalAddress();
521  }
virtual const folly::SocketAddress & getLocalAddress() const noexcept=0
const folly::SocketAddress& proxygen::HTTPTransaction::getLocalAddress ( ) const
inlinenoexcept

Definition at line 527 of file HTTPTransaction.h.

References transport_.

528  {
529  return transport_.getLocalAddress();
530  }
virtual const folly::SocketAddress & getLocalAddress() const noexcept=0
uint32_t proxygen::HTTPTransaction::getMaxDeferredSize ( )
inline

Definition at line 576 of file HTTPTransaction.h.

References folly::pushmi::operators::error(), uint16_t, and uint32_t.

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

576  {
577  return maxDeferredIngress_;
578  }
void proxygen::HTTPTransaction::getPeerAddress ( folly::SocketAddress addr) const
inline

Definition at line 523 of file HTTPTransaction.h.

References transport_.

523  {
524  addr = transport_.getPeerAddress();
525  }
virtual const folly::SocketAddress & getPeerAddress() const noexcept=0
const folly::SocketAddress& proxygen::HTTPTransaction::getPeerAddress ( ) const
inlinenoexcept

Definition at line 532 of file HTTPTransaction.h.

References transport_.

533  {
534  return transport_.getPeerAddress();
535  }
virtual const folly::SocketAddress & getPeerAddress() const noexcept=0
http2::PriorityUpdate proxygen::HTTPTransaction::getPriority ( ) const
inline

Definition at line 488 of file HTTPTransaction.h.

Referenced by TEST_F().

488  {
489  return priority_;
490  }
http2::PriorityUpdate priority_
bool proxygen::HTTPTransaction::getPriorityFallback ( ) const
inline

Definition at line 499 of file HTTPTransaction.h.

499  {
500  return priorityFallback_;
501  }
bool proxygen::HTTPTransaction::getPrioritySampleSummary ( HTTPTransaction::PrioritySampleSummary summary) const

Definition at line 1536 of file HTTPTransaction.cpp.

References prioritySample_.

1537  {
1538  if (prioritySample_) {
1539  prioritySample_->getSummary(summary);
1540  return true;
1541  }
1542  return false;
1543 }
std::unique_ptr< PrioritySample > prioritySample_
std::tuple<uint64_t, uint64_t, double> proxygen::HTTPTransaction::getPrioritySummary ( ) const
inline

Definition at line 492 of file HTTPTransaction.h.

References std::tr1::make_tuple().

const std::set<HTTPCodec::StreamID>& proxygen::HTTPTransaction::getPushedTransactions ( ) const
inline

Get a set of server-pushed transactions associated with this transaction.

Definition at line 1071 of file HTTPTransaction.h.

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

1071  {
1072  return pushedTransactions_;
1073  }
std::set< HTTPCodec::StreamID > pushedTransactions_
virtual const Window& proxygen::HTTPTransaction::getReceiveWindow ( ) const
inlinevirtual

Get the receive window of the transaction

Definition at line 572 of file HTTPTransaction.h.

572  {
573  return recvWindow_;
574  }
int32_t proxygen::HTTPTransaction::getRecvToAck ( ) const

Definition at line 1349 of file HTTPTransaction.cpp.

References recvToAck_.

1349  {
1350  return recvToAck_;
1351 }
uint32_t proxygen::HTTPTransaction::getSequenceNumber ( ) const
inline

Definition at line 471 of file HTTPTransaction.h.

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

471 { return seqNo_; }
HTTPSessionStats* proxygen::HTTPTransaction::getSessionStats ( ) const
inline

Definition at line 545 of file HTTPTransaction.h.

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

545  {
546  return stats_;
547  }
HTTPSessionStats * stats_
const wangle::TransportInfo& proxygen::HTTPTransaction::getSetupTransportInfo ( ) const
inlinenoexcept

Definition at line 537 of file HTTPTransaction.h.

References transport_.

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

537  {
539  }
virtual const wangle::TransportInfo & getSetupTransportInfo() const noexcept=0
const Transport& proxygen::HTTPTransaction::getTransport ( ) const
inline

Definition at line 473 of file HTTPTransaction.h.

References transport_.

473 { return transport_; }
Transport& proxygen::HTTPTransaction::getTransport ( )
inline

Definition at line 475 of file HTTPTransaction.h.

References transport_.

475 { return transport_; }
bool proxygen::HTTPTransaction::hasIdleTimeout ( ) const
inline

Does this transaction have an idle timeout set?

Definition at line 1033 of file HTTPTransaction.h.

1033  {
1034  return transactionTimeout_.hasValue();
1035  }
FOLLY_CPP14_CONSTEXPR bool hasValue() const noexcept
Definition: Optional.h:300
folly::Optional< std::chrono::milliseconds > transactionTimeout_
bool proxygen::HTTPTransaction::hasPendingBody ( ) const
inline

Definition at line 1220 of file HTTPTransaction.h.

1220  {
1221  return deferredEgressBody_.chainLength() > 0;
1222  }
size_t chainLength() const
Definition: IOBufQueue.h:492
folly::IOBufQueue deferredEgressBody_
bool proxygen::HTTPTransaction::hasPendingEOM ( ) const
inlineprivate

Definition at line 1289 of file HTTPTransaction.h.

Referenced by sendDeferredBody().

1289  {
1290  return deferredEgressBody_.chainLength() == 0 &&
1292  }
size_t chainLength() const
Definition: IOBufQueue.h:492
folly::IOBufQueue deferredEgressBody_
void proxygen::HTTPTransaction::incrementPendingByteEvents ( )
inline

HTTPTransaction will not detach until it has 0 pending byte events. If you call incrementPendingByteEvents, you must make a corresponding call to decrementPendingByteEvents or the transaction will never be destroyed.

Definition at line 1137 of file HTTPTransaction.h.

References max.

Referenced by TEST_F().

1137  {
1140  }
LogLevel max
Definition: LogLevel.cpp:31
bool proxygen::HTTPTransaction::isDownstream ( ) const
inline
bool proxygen::HTTPTransaction::isEgressComplete ( ) const
inline
Returns
true iff the egress EOM has been flushed to the socket.

Definition at line 753 of file HTTPTransaction.h.

Referenced by onDelayedDestroy(), onError(), onIngressTimeout(), and sendHeadersWithOptionalEOM().

753  {
754  return egressState_ == HTTPTransactionEgressSM::State::SendingDone;
755  }
HTTPTransactionEgressSM::State egressState_
bool proxygen::HTTPTransaction::isEgressEOMQueued ( ) const
inline
Returns
true iff sendEOM() has been called, but the eom has not been flushed to the socket yet.

Definition at line 746 of file HTTPTransaction.h.

Referenced by notifyTransportPendingEgress(), and sendDeferredBody().

746  {
747  return egressState_ == HTTPTransactionEgressSM::State::EOMQueued;
748  }
HTTPTransactionEgressSM::State egressState_
bool proxygen::HTTPTransaction::isEgressEOMSeen ( ) const
inline
Returns
true iff sendEOM() has been called.

Definition at line 768 of file HTTPTransaction.h.

768  {
769  return isEgressEOMQueued() || isEgressComplete();
770  }
bool proxygen::HTTPTransaction::isEgressPaused ( ) const
inline
Returns
true iff egress processing is paused for the handler

Definition at line 941 of file HTTPTransaction.h.

bool proxygen::HTTPTransaction::isEgressStarted ( ) const
inline
Returns
true if egress has started on this transaction.

Definition at line 738 of file HTTPTransaction.h.

738  {
739  return egressState_ != HTTPTransactionEgressSM::State::Start;
740  }
HTTPTransactionEgressSM::State egressState_
bool proxygen::HTTPTransaction::isEnqueued ( ) const
inlineprivate
bool proxygen::HTTPTransaction::isExpectingIngress ( ) const
private

Definition at line 483 of file HTTPTransaction.cpp.

References ingressPaused_, isExpectingWindowUpdate(), and isIngressEOMSeen().

Referenced by updateReadTimeout().

483  {
484  return (!ingressPaused_ &&
486 }
bool isExpectingWindowUpdate() const
bool proxygen::HTTPTransaction::isExpectingWindowUpdate ( ) const
private

Definition at line 479 of file HTTPTransaction.cpp.

References proxygen::Window::getSize(), sendWindow_, and useFlowControl_.

Referenced by isExpectingIngress(), onError(), onIngressTimeout(), and sendBodyNow().

479  {
480  return (useFlowControl_ && sendWindow_.getSize() <= 0);
481 }
int32_t getSize() const
Definition: Window.cpp:23
bool proxygen::HTTPTransaction::isExTransaction ( ) const
inline

Definition at line 1015 of file HTTPTransaction.h.

1015  {
1016  return exAttributes_.has_value();
1017  }
folly::Optional< HTTPCodec::ExAttributes > exAttributes_
bool proxygen::HTTPTransaction::isFlowControlPaused ( ) const
inline
Returns
true iff egress processing is paused due to flow control to the handler

Definition at line 947 of file HTTPTransaction.h.

bool proxygen::HTTPTransaction::isIngressComplete ( ) const
inline
Returns
true iff the handler has been notified of the ingress EOM.

Definition at line 724 of file HTTPTransaction.h.

Referenced by onDelayedDestroy(), onError(), processIngressBody(), processIngressChunkComplete(), processIngressChunkHeader(), processIngressEOM(), processIngressHeadersComplete(), processIngressTrailers(), processIngressUpgrade(), and resumeIngress().

724  {
725  return ingressState_ == HTTPTransactionIngressSM::State::ReceivingDone;
726  }
HTTPTransactionIngressSM::State ingressState_
bool proxygen::HTTPTransaction::isIngressEOMQueued ( ) const
inline
Returns
true iff the ingress EOM has been queued in HTTPTransaction but the handler has not yet been notified of this event.

Definition at line 717 of file HTTPTransaction.h.

717  {
718  return ingressState_ == HTTPTransactionIngressSM::State::EOMQueued;
719  }
HTTPTransactionIngressSM::State ingressState_
bool proxygen::HTTPTransaction::isIngressEOMSeen ( ) const
inline
bool proxygen::HTTPTransaction::isIngressPaused ( ) const
inline
Returns
true iff ingress processing is paused for the handler

Definition at line 905 of file HTTPTransaction.h.

References uint64_t.

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

bool proxygen::HTTPTransaction::isIngressStarted ( ) const
inline
Returns
true if ingress has started on this transaction.

Definition at line 709 of file HTTPTransaction.h.

709  {
710  return ingressState_ != HTTPTransactionIngressSM::State::Start;
711  }
HTTPTransactionIngressSM::State ingressState_
bool proxygen::HTTPTransaction::isPrioritySampled ( ) const
inline

Definition at line 1195 of file HTTPTransaction.h.

References uint64_t.

Referenced by sendBodyNow().

1195  {
1196  return prioritySample_ != nullptr;
1197  }
std::unique_ptr< PrioritySample > prioritySample_
bool proxygen::HTTPTransaction::isPushed ( ) const
inline

True if this transaction is a server push transaction

Definition at line 1011 of file HTTPTransaction.h.

Referenced by proxygen::HTTPSession::createTransaction(), proxygen::HTTPSession::decrementTransactionCount(), onIngressHeadersComplete(), proxygen::HTTPSession::onMessageBegin(), and sendHeadersWithOptionalEOM().

1011  {
1012  return assocStreamId_.has_value();
1013  }
folly::Optional< HTTPCodec::StreamID > assocStreamId_
bool proxygen::HTTPTransaction::isRemoteInitiated ( ) const
inline
Returns
true iff the remote side initiated this transaction.

Definition at line 760 of file HTTPTransaction.h.

References proxygen::DOWNSTREAM, and proxygen::UPSTREAM.

Referenced by HTTPTransaction(), and proxygen::HTTPSession::onHeadersComplete().

bool proxygen::HTTPTransaction::isUnidirectional ( ) const
inline

Definition at line 1019 of file HTTPTransaction.h.

1019  {
1020  return isExTransaction() && exAttributes_->unidirectional;
1021  }
folly::Optional< HTTPCodec::ExAttributes > exAttributes_
bool proxygen::HTTPTransaction::isUpstream ( ) const
inline
void proxygen::HTTPTransaction::markEgressComplete ( )
private

Causes isEgressComplete() to return true, removes any queued egress, and cancels the write timeout.

Definition at line 503 of file HTTPTransaction.cpp.

References folly::IOBufQueue::chainLength(), deferredEgressBody_, dequeue(), egressState_, int64_t, isEnqueued(), folly::IOBufQueue::move(), proxygen::HTTPTransaction::Transport::notifyEgressBodyBuffered(), and transport_.

Referenced by onEgressTimeout(), onError(), onIngressTimeout(), processIngressEOM(), and sendAbort().

503  {
504  VLOG(4) << "Marking egress complete on " << *this;
506  int64_t deferredEgressBodyBytes =
507  folly::to<int64_t>(deferredEgressBody_.chainLength());
508  transport_.notifyEgressBodyBuffered(-deferredEgressBodyBytes);
509  }
511  if (isEnqueued()) {
512  dequeue();
513  }
514  egressState_ = HTTPTransactionEgressSM::State::SendingDone;
515 }
size_t chainLength() const
Definition: IOBufQueue.h:492
std::unique_ptr< folly::IOBuf > move()
Definition: IOBufQueue.h:459
virtual void notifyEgressBodyBuffered(int64_t bytes) noexcept=0
HTTPTransactionEgressSM::State egressState_
folly::IOBufQueue deferredEgressBody_
void proxygen::HTTPTransaction::markIngressComplete ( )
private

Causes isIngressComplete() to return true, removes any queued ingress, and cancels the read timeout.

Definition at line 496 of file HTTPTransaction.cpp.

References folly::HHWheelTimer::Callback::cancelTimeout(), deferredIngress_, and ingressState_.

Referenced by onError(), onIngressTimeout(), and sendAbort().

496  {
497  VLOG(4) << "Marking ingress complete on " << *this;
498  ingressState_ = HTTPTransactionIngressSM::State::ReceivingDone;
499  deferredIngress_.reset();
500  cancelTimeout();
501 }
HTTPTransactionIngressSM::State ingressState_
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
bool proxygen::HTTPTransaction::maybeDelayForRateLimit ( )
private

Definition at line 888 of file HTTPTransaction.cpp.

References count, egressLimitBytesPerMs_, egressRateLimited_, proxygen::getCurrentTime(), int64_t, proxygen::millisecondsBetween(), notifyTransportPendingEgress(), numLimitedBytesEgressed_, rateLimitCallback_, folly::HHWheelTimer::scheduleTimeout(), startRateLimit_, and timer_.

Referenced by sendDeferredBody().

888  {
889  if (egressLimitBytesPerMs_ <= 0) {
890  // No rate limiting
891  return false;
892  }
893 
894  if (numLimitedBytesEgressed_ == 0) {
895  // If we haven't egressed any bytes yet, don't delay.
896  return false;
897  }
898 
899  int64_t limitedDurationMs = (int64_t) millisecondsBetween(
900  getCurrentTime(),
902  ).count();
903 
904  // Algebra! Try to figure out the next time send where we'll
905  // be allowed to send at least 1 full packet's worth. The
906  // formula we're using is:
907  // (bytesSoFar + packetSize) / (timeSoFar + delay) == targetRateLimit
908  std::chrono::milliseconds requiredDelay(
909  (
910  ((int64_t)numLimitedBytesEgressed_ + kApproximateMTU) -
911  ((int64_t)egressLimitBytesPerMs_ * limitedDurationMs)
913  );
914 
915  if (requiredDelay.count() <= 0) {
916  // No delay required
917  return false;
918  }
919 
920  if (requiredDelay > kRateLimitMaxDelay) {
921  // The delay should never be this long
922  VLOG(4) << "ratelim: Required delay too long (" << requiredDelay.count()
923  << "ms), ignoring";
924  return false;
925  }
926 
927  // Delay required
928 
929  egressRateLimited_ = true;
930 
931  if (timer_) {
932  timer_->scheduleTimeout(&rateLimitCallback_, requiredDelay);
933  }
934 
936  return true;
937 }
std::chrono::milliseconds millisecondsBetween(std::chrono::time_point< ClockType > finish, std::chrono::time_point< ClockType > start)
Definition: Time.h:85
proxygen::TimePoint startRateLimit_
void scheduleTimeout(Callback *callback, std::chrono::milliseconds timeout)
RateLimitCallback rateLimitCallback_
folly::HHWheelTimer * timer_
int * count
std::chrono::time_point< ClockType > getCurrentTime()
Definition: Time.h:41
bool proxygen::HTTPTransaction::mustQueueIngress ( ) const
private
virtual bool proxygen::HTTPTransaction::needToBlockForReplaySafety ( ) const
inlinevirtual

Definition at line 1189 of file HTTPTransaction.h.

References int32_t, and transport_.

1189  {
1191  }
virtual bool needToBlockForReplaySafety() const =0
virtual HTTPTransaction* proxygen::HTTPTransaction::newExTransaction ( HTTPTransactionHandler handler,
bool  unidirectional = false 
)
inlinevirtual

Create a new extended transaction associated with this transaction, and assign the given handler and priority.

Returns
the new transaction for pubsub, or nullptr if a new push transaction is impossible right now.

Definition at line 984 of file HTTPTransaction.h.

References transport_.

Referenced by proxygen::RequestHandlerAdaptor::newExMessage().

985  {
986  auto txn = transport_.newExTransaction(handler, id_, unidirectional);
987  if (txn) {
988  exTransactions_.insert(txn->getID());
989  }
990  return txn;
991  }
HTTPCodec::StreamID id_
virtual HTTPTransaction * newExTransaction(HTTPTransaction::Handler *handler, HTTPCodec::StreamID controlStream, bool unidirectional) noexcept=0
void handler(int, siginfo_t *, void *)
std::set< HTTPCodec::StreamID > exTransactions_
virtual HTTPTransaction* proxygen::HTTPTransaction::newPushedTransaction ( HTTPPushTransactionHandler handler)
inlinevirtual

Create a new pushed transaction associated with this transaction, and assign the given handler and priority.

Returns
the new transaction for the push, or nullptr if a new push transaction is impossible right now.

Definition at line 965 of file HTTPTransaction.h.

References transport_.

Referenced by proxygen::RequestHandlerAdaptor::newPushedResponse(), and TEST_F().

966  {
967  if (isEgressEOMSeen()) {
968  return nullptr;
969  }
971  if (txn) {
972  pushedTransactions_.insert(txn->getID());
973  }
974  return txn;
975  }
HTTPCodec::StreamID id_
void handler(int, siginfo_t *, void *)
std::set< HTTPCodec::StreamID > pushedTransactions_
virtual HTTPTransaction * newPushedTransaction(HTTPCodec::StreamID assocStreamId, HTTPTransaction::PushHandler *handler) noexcept=0
void proxygen::HTTPTransaction::notifyTransportPendingEgress ( )
private

Definition at line 1181 of file HTTPTransaction.cpp.

References folly::IOBufQueue::chainLength(), proxygen::HTTP2PriorityQueueBase::clearPendingEgress(), deferredEgressBody_, egressQueue_, egressRateLimited_, proxygen::Window::getSize(), folly::gen::guard(), int64_t, isEgressEOMQueued(), isEnqueued(), proxygen::HTTPTransaction::Transport::notifyEgressBodyBuffered(), proxygen::HTTPTransaction::Transport::notifyPendingEgress(), queueHandle_, sendWindow_, proxygen::HTTP2PriorityQueueBase::signalPendingEgress(), transport_, updateHandlerPauseState(), and useFlowControl_.

Referenced by maybeDelayForRateLimit(), onIngressSetSendWindow(), onIngressWindowUpdate(), rateLimitTimeoutExpired(), sendBody(), sendDeferredBody(), and sendEOM().

1181  {
1182  DestructorGuard guard(this);
1183  if (!egressRateLimited_ &&
1185  isEgressEOMQueued()) &&
1186  (!useFlowControl_ || sendWindow_.getSize() > 0)) {
1187  // Egress isn't paused, we have something to send, and flow
1188  // control isn't blocking us.
1189  if (!isEnqueued()) {
1190  // Insert into the queue and let the session know we've got something
1194  }
1195  } else if (isEnqueued()) {
1196  // Nothing to send, or not allowed to send right now.
1197  int64_t deferredEgressBodyBytes =
1198  folly::to<int64_t>(deferredEgressBody_.chainLength());
1199  transport_.notifyEgressBodyBuffered(-deferredEgressBodyBytes);
1201  }
1203 }
size_t chainLength() const
Definition: IOBufQueue.h:492
int32_t getSize() const
Definition: Window.cpp:23
virtual void notifyEgressBodyBuffered(int64_t bytes) noexcept=0
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
HTTP2PriorityQueueBase::Handle queueHandle_
folly::IOBufQueue deferredEgressBody_
virtual void notifyPendingEgress() noexcept=0
HTTP2PriorityQueueBase & egressQueue_
virtual void clearPendingEgress(Handle h)=0
virtual void signalPendingEgress(Handle h)=0
void proxygen::HTTPTransaction::onDelayedDestroy ( bool  delayed)
overrideprivatevirtual

Implement onDelayedDestroy in subclasses. onDelayedDestroy() is invoked when the object is potentially being destroyed.

Parameters
delayedThis parameter is true if destruction was delayed because of a DestructorGuard object, or false if onDelayedDestroy() is being called directly from the destructor.

Implements folly::DelayedDestructionBase.

Definition at line 111 of file HTTPTransaction.cpp.

References deleting_, proxygen::HTTPTransaction::Transport::detach(), proxygen::HTTPTransactionHandler::detachTransaction(), proxygen::Window::getOutstanding(), handler_, isEgressComplete(), isEnqueued(), isIngressComplete(), proxygen::HTTPTransaction::Transport::notifyIngressBodyProcessed(), pendingByteEvents_, recvWindow_, transport_, and transportCallback_.

111  {
113  || pendingByteEvents_ > 0 || deleting_) {
114  return;
115  }
116  VLOG(4) << "destroying transaction " << *this;
117  deleting_ = true;
118  if (handler_) {
120  handler_ = nullptr;
121  }
122  transportCallback_ = nullptr;
123  const auto bytesBuffered = recvWindow_.getOutstanding();
124  if (bytesBuffered) {
125  transport_.notifyIngressBodyProcessed(bytesBuffered);
126  }
127  transport_.detach(this);
128  (void)delayed; // prevent unused variable warnings
129 }
uint32_t getOutstanding() const
Definition: Window.cpp:37
virtual void detachTransaction() noexcept=0
virtual void detach(HTTPTransaction *txn) noexcept=0
virtual void notifyIngressBodyProcessed(uint32_t bytes) noexcept=0
TransportCallback * transportCallback_
void proxygen::HTTPTransaction::onDeltaSendWindowSize ( int32_t  windowDelta)
private
void proxygen::HTTPTransaction::onEgressBodyFirstByte ( )

Invoked by the session when the first byte is flushed.

Definition at line 701 of file HTTPTransaction.cpp.

References proxygen::HTTPTransactionTransportCallback::firstByteFlushed(), g(), and transportCallback_.

Referenced by proxygen::HTTPSessionBase::handleLastByteEvents().

701  {
702  DestructorGuard g(this);
703  if (transportCallback_) {
705  }
706 }
TransportCallback * transportCallback_
virtual void firstByteFlushed() noexcept=0
g_t g(f_t)
void proxygen::HTTPTransaction::onEgressBodyLastByte ( )

Invoked by the session when the last byte is flushed.

Definition at line 708 of file HTTPTransaction.cpp.

References g(), proxygen::HTTPTransactionTransportCallback::lastByteFlushed(), and transportCallback_.

Referenced by proxygen::HTTPSessionBase::handleLastByteEvents().

708  {
709  DestructorGuard g(this);
710  if (transportCallback_) {
712  }
713 }
virtual void lastByteFlushed() noexcept=0
TransportCallback * transportCallback_
g_t g(f_t)
void proxygen::HTTPTransaction::onEgressHeaderFirstByte ( )

Invoked by the session when the first header byte is flushed.

Definition at line 694 of file HTTPTransaction.cpp.

References proxygen::HTTPTransactionTransportCallback::firstHeaderByteFlushed(), g(), and transportCallback_.

694  {
695  DestructorGuard g(this);
696  if (transportCallback_) {
698  }
699 }
virtual void firstHeaderByteFlushed() noexcept=0
TransportCallback * transportCallback_
g_t g(f_t)
void proxygen::HTTPTransaction::onEgressLastByteAck ( std::chrono::milliseconds  latency)

Invoked when the ACK_LATENCY event is delivered

Parameters
latencythe time between the moment when the last byte was sent and the moment when we received the ACK from the client

Definition at line 722 of file HTTPTransaction.cpp.

References g(), proxygen::HTTPTransactionTransportCallback::lastByteAcked(), and transportCallback_.

722  {
723  DestructorGuard g(this);
724  if (transportCallback_) {
726  }
727 }
virtual void lastByteAcked(std::chrono::milliseconds latency) noexcept=0
TransportCallback * transportCallback_
g_t g(f_t)
void proxygen::HTTPTransaction::onEgressTimeout ( )

Invoked by the session when there is a timeout on the egress stream.

Definition at line 681 of file HTTPTransaction.cpp.

References proxygen::HTTPException::EGRESS, g(), handler_, id_, proxygen::kErrorTimeout, markEgressComplete(), onError(), and proxygen::Exception::setProxygenError().

681  {
682  DestructorGuard g(this);
683  VLOG(4) << "egress timeout on " << *this;
684  if (handler_) {
685  HTTPException ex(HTTPException::Direction::EGRESS,
686  folly::to<std::string>("egress timeout, streamID=", id_));
687  ex.setProxygenError(kErrorTimeout);
688  onError(ex);
689  } else {
691  }
692 }
void onError(const HTTPException &error)
HTTPCodec::StreamID id_
g_t g(f_t)
void proxygen::HTTPTransaction::onEgressTrackedByte ( )

Invoked by the session when the tracked byte is flushed.

Definition at line 715 of file HTTPTransaction.cpp.

References g(), proxygen::HTTPTransactionTransportCallback::trackedByteFlushed(), and transportCallback_.

715  {
716  DestructorGuard g(this);
717  if (transportCallback_) {
719  }
720 }
TransportCallback * transportCallback_
g_t g(f_t)
void proxygen::HTTPTransaction::onError ( const HTTPException error)

Invoked by the session when there is an error (e.g., invalid syntax, TCP RST) in either the ingress or egress stream. Note that this message is processed immediately even if this transaction normally would queue ingress.

Parameters
errorDetails for the error. This exception also has information about whether the error applies to the ingress, egress, or both directions of the transaction

Definition at line 536 of file HTTPTransaction.cpp.

References aborted_, proxygen::HTTPException::EGRESS, proxygen::FLOW_CONTROL_ERROR, g(), proxygen::HTTPException::getCodecStatusCode(), proxygen::HTTPException::getDirection(), proxygen::Exception::getProxygenError(), handler_, proxygen::HTTPException::hasCodecStatusCode(), proxygen::HTTPException::INGRESS, proxygen::HTTPException::INGRESS_AND_EGRESS, ingressErrorSeen_, isEgressComplete(), isExpectingWindowUpdate(), isIngressComplete(), isIngressEOMSeen(), proxygen::kErrorStreamAbort, proxygen::kErrorWriteTimeout, markEgressComplete(), markIngressComplete(), proxygen::HTTPTransactionHandler::onError(), and sendAbort().

Referenced by proxygen::HTTPSessionBase::handleErrorDirectly(), proxygen::HTTPSession::onAbort(), onEgressTimeout(), proxygen::HTTPSession::onError(), onIngressBody(), onIngressEOM(), onIngressTimeout(), proxygen::HTTPSession::onMessageBegin(), sendBodyNow(), proxygen::HTTPSession::shutdownTransport(), TEST(), and validateIngressStateTransition().

536  {
537  DestructorGuard g(this);
538 
539  const bool wasAborted = aborted_; // see comment below
540  const bool wasEgressComplete = isEgressComplete();
541  const bool wasIngressComplete = isIngressComplete();
542  bool notify = (handler_);
543  HTTPException::Direction direction = error.getDirection();
544 
545  if (direction == HTTPException::Direction::INGRESS &&
547  // we got an ingress error, we've seen the entire message, but we're
548  // expecting more (window updates). These aren't coming, convert to
549  // INGRESS_AND_EGRESS
550  VLOG(4) << "Converting ingress error to ingress+egress due to"
551  " flow control, and aborting " << *this;
554  }
555 
556  if (error.getProxygenError() == kErrorStreamAbort) {
557  DCHECK(error.getDirection() ==
559  aborted_ = true;
560  } else if (error.hasCodecStatusCode()) {
561  DCHECK(error.getDirection() ==
563  sendAbort(error.getCodecStatusCode());
564  }
565 
566  switch (direction) {
570  if (wasEgressComplete && wasIngressComplete &&
571  // We mark egress complete before we get acknowledgement of the
572  // write segment finishing successfully.
573  // TODO: instead of using DestructorGuard hacks to keep txn around,
574  // use an explicit callback function and set egress complete after
575  // last byte flushes (or egress error occurs), see #3912823
576  (error.getProxygenError() != kErrorWriteTimeout || wasAborted)) {
577  notify = false;
578  }
579  break;
582  if (!wasEgressComplete && isIngressEOMSeen() && ingressErrorSeen_) {
583  // we've already seen an ingress error but we ignored it, hoping the
584  // handler would resume and read our queued EOM. Now both sides are
585  // dead and we need to kill this transaction.
587  }
588  if (wasEgressComplete) {
589  notify = false;
590  }
591  break;
593  if (isIngressEOMSeen()) {
594  // Not an error, for now
595  ingressErrorSeen_ = true;
596  return;
597  }
599  if (wasIngressComplete) {
600  notify = false;
601  }
602  break;
603  }
604  if (notify && handler_) {
605  // mark egress complete may result in handler detaching
607  }
608 }
virtual void onError(const HTTPException &error) noexcept=0
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
bool isExpectingWindowUpdate() const
g_t g(f_t)
bool proxygen::HTTPTransaction::onExTransaction ( HTTPTransaction txn)

Invoked by the session when a new ExTransaction arrives. The txn's handler will be notified and is responsible for installing a handler. If no handler is installed in the callback, the transaction will be aborted.

Definition at line 1279 of file HTTPTransaction.cpp.

References proxygen::ERROR, exTransactions_, g(), getControlStream(), getHandler(), getID(), handler_, id_, and proxygen::HTTPTransactionHandler::onExTransaction().

1279  {
1280  DestructorGuard g(this);
1281  CHECK_EQ(*(exTxn->getControlStream()), id_);
1282  if (!handler_) {
1283  LOG(ERROR) << "Cannot add a exTxn to an unhandled txn";
1284  return false;
1285  }
1286  handler_->onExTransaction(exTxn);
1287  if (!exTxn->getHandler()) {
1288  LOG(ERROR) << "Failed to create a handler for ExTransaction";
1289  return false;
1290  }
1291  exTransactions_.insert(exTxn->getID());
1292  return true;
1293 }
HTTPCodec::StreamID id_
std::set< HTTPCodec::StreamID > exTransactions_
virtual void onExTransaction(HTTPTransaction *) noexcept
g_t g(f_t)
void proxygen::HTTPTransaction::onGoaway ( ErrorCode  code)

Invoked by the session when a GOAWAY frame is received. TODO: we may consider exposing the additional debug data here in the future.

Parameters
codeThe error code received in the GOAWAY frame

Definition at line 610 of file HTTPTransaction.cpp.

References g(), handler_, and proxygen::HTTPTransactionHandler::onGoaway().

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

610  {
611  DestructorGuard g(this);
612  VLOG(4) << "received GOAWAY notification on " << *this;
613  // This callback can be received at any time and does not affect this
614  // transaction's ingress or egress state machines. If it would have
615  // affected this transaction's state, we would have received onError()
616  // instead.
617  if (handler_) {
618  handler_->onGoaway(code);
619  }
620 }
virtual void onGoaway(ErrorCode) noexcept
g_t g(f_t)
void proxygen::HTTPTransaction::onIngressBody ( std::unique_ptr< folly::IOBuf chain,
uint16_t  padding 
)

Invoked by the session when some or all of the ingress entity-body has been parsed.

Definition at line 217 of file HTTPTransaction.cpp.

References proxygen::HTTPEvent::BODY, proxygen::HTTPTransactionTransportCallback::bodyBytesReceived(), checkCreateDeferredIngress(), folly::IOBuf::computeChainDataLength(), deferredIngress_, proxygen::ERROR, expectedContentLengthRemaining_, proxygen::FLOW_CONTROL_ERROR, FOLLY_SCOPED_TRACE_SECTION, proxygen::Window::free(), g(), proxygen::Window::getCapacity(), proxygen::Window::getOutstanding(), handler_, folly::Optional< Value >::hasValue(), id_, proxygen::HTTPException::INGRESS, isIngressEOMSeen(), proxygen::kErrorParseBody, folly::gen::move, mustQueueIngress(), onError(), processIngressBody(), recvToAck_, recvWindow_, proxygen::Window::reserve(), sendAbort(), proxygen::Exception::setProxygenError(), proxygen::STREAM_CLOSED, transportCallback_, useFlowControl_, validateIngressStateTransition(), and folly::Optional< Value >::value().

Referenced by proxygen::HTTPSessionBase::onBodyImpl(), and DownstreamTransactionTest::setupRequestResponseFlow().

218  {
219  FOLLY_SCOPED_TRACE_SECTION("HTTPTransaction - onIngressBody");
220  DestructorGuard g(this);
221  if (isIngressEOMSeen()) {
223  return;
224  }
225  auto len = chain->computeChainDataLength();
226  if (len == 0) {
227  return;
228  }
230  HTTPTransactionIngressSM::Event::onBody)) {
231  return;
232  }
234  if (expectedContentLengthRemaining_.value() >= len) {
237  } else {
238  auto errorMsg = folly::to<std::string>(
239  "Content-Length/body mismatch: received=",
240  len,
241  " expecting no more than ",
243  LOG(ERROR) << errorMsg << " " << *this;
244  if (handler_) {
245  HTTPException ex(HTTPException::Direction::INGRESS, errorMsg);
246  ex.setProxygenError(kErrorParseBody);
247  onError(ex);
248  }
249  return;
250  }
251  }
252  if (transportCallback_) {
254  }
255  // register the bytes in the receive window
256  if (!recvWindow_.reserve(len + padding, useFlowControl_)) {
257  LOG(ERROR) << "recvWindow_.reserve failed with len=" << len
258  << " padding=" << padding
259  << " capacity=" << recvWindow_.getCapacity()
260  << " outstanding=" << recvWindow_.getOutstanding()
261  << " " << *this ;
263  return;
264  } else {
265  CHECK(recvWindow_.free(padding));
266  recvToAck_ += padding;
267  }
268  if (mustQueueIngress()) {
271  std::move(chain));
272  VLOG(4) << "Queued ingress event of type " << HTTPEvent::Type::BODY
273  << " size=" << len << " " << *this;
274  } else {
275  CHECK(recvWindow_.free(len));
276  processIngressBody(std::move(chain), len);
277  }
278 }
#define FOLLY_SCOPED_TRACE_SECTION(arg,...)
void onError(const HTTPException &error)
HTTPCodec::StreamID id_
uint32_t getCapacity() const
Definition: Window.cpp:32
virtual void bodyBytesReceived(size_t size) noexcept=0
uint32_t getOutstanding() const
Definition: Window.cpp:37
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
bool reserve(uint32_t amount, bool strict=true)
Definition: Window.cpp:41
folly::Optional< uint64_t > expectedContentLengthRemaining_
FOLLY_CPP14_CONSTEXPR bool hasValue() const noexcept
Definition: Optional.h:300
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
std::size_t computeChainDataLength() const
Definition: IOBuf.cpp:501
TransportCallback * transportCallback_
g_t g(f_t)
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268
void processIngressBody(std::unique_ptr< folly::IOBuf > chain, size_t len)
bool free(uint32_t amount)
Definition: Window.cpp:63
void proxygen::HTTPTransaction::onIngressChunkComplete ( )

Invoked by the session when the CRLF terminating a chunk has been parsed.

Definition at line 336 of file HTTPTransaction.cpp.

References checkCreateDeferredIngress(), proxygen::HTTPEvent::CHUNK_COMPLETE, deferredIngress_, id_, mustQueueIngress(), processIngressChunkComplete(), and validateIngressStateTransition().

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

336  {
338  HTTPTransactionIngressSM::Event::onChunkComplete)) {
339  return;
340  }
341  if (mustQueueIngress()) {
344  VLOG(4) << "Queued ingress event of type "
345  << HTTPEvent::Type::CHUNK_COMPLETE << " " << *this;
346  } else {
348  }
349 }
HTTPCodec::StreamID id_
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
void proxygen::HTTPTransaction::onIngressChunkHeader ( size_t  length)

Invoked by the session when a chunk header has been parsed.

Definition at line 310 of file HTTPTransaction.cpp.

References checkCreateDeferredIngress(), proxygen::HTTPEvent::CHUNK_HEADER, deferredIngress_, id_, mustQueueIngress(), processIngressChunkHeader(), and validateIngressStateTransition().

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

310  {
312  HTTPTransactionIngressSM::Event::onChunkHeader)) {
313  return;
314  }
315  if (mustQueueIngress()) {
318  VLOG(4) << "Queued ingress event of type " << HTTPEvent::Type::CHUNK_HEADER
319  << " size=" << length << " " << *this;
320  } else {
322  }
323 }
void processIngressChunkHeader(size_t length)
HTTPCodec::StreamID id_
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
void proxygen::HTTPTransaction::onIngressEOM ( )

Invoked by the session when the ingress message is complete.

Definition at line 414 of file HTTPTransaction.cpp.

References checkCreateDeferredIngress(), deferredIngress_, proxygen::ERROR, expectedContentLengthRemaining_, extraResponseExpected(), handler_, folly::Optional< Value >::hasValue(), id_, proxygen::HTTPException::INGRESS, isIngressEOMSeen(), isUpstream(), proxygen::kErrorParseBody, proxygen::HTTPEvent::MESSAGE_COMPLETE, mustQueueIngress(), onError(), processIngressEOM(), sendAbort(), proxygen::Exception::setProxygenError(), proxygen::STREAM_CLOSED, updateReadTimeout(), validateIngressStateTransition(), and folly::Optional< Value >::value().

Referenced by proxygen::HTTPSession::onMessageComplete(), and DownstreamTransactionTest::setupRequestResponseFlow().

414  {
415  if (isIngressEOMSeen()) {
416  // This can happen when HTTPSession calls onIngressEOF()
418  return;
419  }
422  auto errorMsg = folly::to<std::string>(
423  "Content-Length/body mismatch: expecting another ",
425  LOG(ERROR) << errorMsg << " " << *this;
426  if (handler_) {
427  HTTPException ex(HTTPException::Direction::INGRESS, errorMsg);
428  ex.setProxygenError(kErrorParseBody);
429  onError(ex);
430  }
431  return;
432  }
433 
434  // TODO: change the codec to not give an EOM callback after a 100 response?
435  // We could then delete the below 'if'
436  if (isUpstream() && extraResponseExpected()) {
437  VLOG(4) << "Ignoring EOM on initial 100 response on " << *this;
438  return;
439  }
441  HTTPTransactionIngressSM::Event::onEOM)) {
442  return;
443  }
444  // We need to update the read timeout here. We're not likely to be
445  // expecting any more ingress, and the timer should be cancelled
446  // immediately. If we are expecting more, this will reset the timer.
448  if (mustQueueIngress()) {
451  VLOG(4) << "Queued ingress event of type "
452  << HTTPEvent::Type::MESSAGE_COMPLETE << " " << *this;
453  } else {
455  }
456 }
void onError(const HTTPException &error)
HTTPCodec::StreamID id_
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
folly::Optional< uint64_t > expectedContentLengthRemaining_
FOLLY_CPP14_CONSTEXPR bool hasValue() const noexcept
Definition: Optional.h:300
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
virtual bool extraResponseExpected() const
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268
void proxygen::HTTPTransaction::onIngressHeadersComplete ( std::unique_ptr< HTTPMessage msg)

Invoked by the session when the ingress headers are complete

Definition at line 158 of file HTTPTransaction.cpp.

References checkCreateDeferredIngress(), proxygen::CONNECT, deferredIngress_, proxygen::ERROR, expectedContentLengthRemaining_, g(), proxygen::HTTPTransaction::Transport::getCodec(), proxygen::HTTPCodec::getHPACKTableInfo(), proxygen::HTTPCodec::getProtocol(), proxygen::HEAD, proxygen::HTTPTransactionTransportCallback::headerBytesReceived(), proxygen::HTTPEvent::HEADERS_COMPLETE, headRequest_, proxygen::HTTP_2, proxygen::HTTP_HEADER_CONTENT_LENGTH, id_, isPushed(), isUpstream(), lastResponseStatus_, folly::gen::move, mustQueueIngress(), processIngressHeadersComplete(), proxygen::RFC2616::responseBodyMustBeEmpty(), seqNo_, transport_, transportCallback_, updateIngressHPACKTableInfo(), and validateIngressStateTransition().

159  {
160  DestructorGuard g(this);
161  msg->setSeqNo(seqNo_);
162  if (isUpstream() && !isPushed() && msg->isResponse()) {
163  lastResponseStatus_ = msg->getStatusCode();
164  }
166  HTTPTransactionIngressSM::Event::onHeaders)) {
167  return;
168  }
169  if (msg->isRequest()) {
170  headRequest_ = (msg->getMethod() == HTTPMethod::HEAD);
171  }
172 
173  if ((msg->isRequest() && msg->getMethod() != HTTPMethod::CONNECT) ||
174  (msg->isResponse() && !headRequest_ &&
175  !RFC2616::responseBodyMustBeEmpty(msg->getStatusCode()))) {
176  // CONNECT payload has no defined semantics
177  const auto& contentLen =
178  msg->getHeaders().getSingleOrEmpty(HTTP_HEADER_CONTENT_LENGTH);
179  if (!contentLen.empty()) {
180  try {
181  expectedContentLengthRemaining_ = folly::to<uint64_t>(contentLen);
182  } catch (const folly::ConversionError& ex) {
183  LOG(ERROR) << "Invalid content-length: " << contentLen
184  << ", ex=" << ex.what() << *this;
185  }
186  }
187  }
188  if (transportCallback_) {
189  transportCallback_->headerBytesReceived(msg->getIngressHeaderSize());
190  }
193  }
194  if (mustQueueIngress()) {
197  std::move(msg));
198  VLOG(4) << "Queued ingress event of type "
199  << HTTPEvent::Type::HEADERS_COMPLETE << " " << *this;
200  } else {
202  }
203 }
HTTPCodec::StreamID id_
void processIngressHeadersComplete(std::unique_ptr< HTTPMessage > msg)
bool responseBodyMustBeEmpty(unsigned status)
Definition: RFC2616.cpp:54
void updateIngressHPACKTableInfo(HPACKTableInfo)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual HPACKTableInfo getHPACKTableInfo() const
Definition: HTTPCodec.h:338
virtual CodecProtocol getProtocol() const =0
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
folly::Optional< uint64_t > expectedContentLengthRemaining_
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
TransportCallback * transportCallback_
g_t g(f_t)
virtual const HTTPCodec & getCodec() const noexcept=0
virtual void headerBytesReceived(const HTTPHeaderSize &size) noexcept=0
void proxygen::HTTPTransaction::onIngressSetSendWindow ( uint32_t  newWindowSize)

Invoked by the session when the remote endpoint signals that we should change our send window. This is only for versions of HTTP that support per transaction flow control.

Definition at line 665 of file HTTPTransaction.cpp.

References proxygen::ERROR, proxygen::FLOW_CONTROL_ERROR, proxygen::Window::getCapacity(), proxygen::Window::getOutstanding(), notifyTransportPendingEgress(), sendAbort(), sendWindow_, proxygen::Window::setCapacity(), updateReadTimeout(), and useFlowControl_.

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

665  {
666  if (!useFlowControl_) {
667  return;
668  }
670  if (sendWindow_.setCapacity(newWindowSize)) {
672  } else {
673  LOG(ERROR) << "sendWindow_.setCapacity failed with newWindowSize="
674  << newWindowSize << " capacity=" << sendWindow_.getCapacity()
675  << " outstanding=" << sendWindow_.getOutstanding()
676  << " " << *this;
678  }
679 }
uint32_t getCapacity() const
Definition: Window.cpp:32
uint32_t getOutstanding() const
Definition: Window.cpp:37
bool setCapacity(uint32_t capacity)
Definition: Window.cpp:84
void proxygen::HTTPTransaction::onIngressTimeout ( )

Invoked by the session when there is a timeout on the ingress stream. Note that each transaction has its own timer but the session is the effective target of the timer.

Definition at line 622 of file HTTPTransaction.cpp.

References g(), handler_, id_, proxygen::HTTPException::INGRESS, proxygen::HTTPException::INGRESS_AND_EGRESS, isEgressComplete(), isExpectingWindowUpdate(), proxygen::kErrorTimeout, proxygen::kErrorWriteTimeout, markEgressComplete(), markIngressComplete(), onError(), pauseIngress(), proxygen::PROTOCOL_ERROR, proxygen::HTTPException::setCodecStatusCode(), and proxygen::Exception::setProxygenError().

622  {
623  DestructorGuard g(this);
624  VLOG(4) << "ingress timeout on " << *this;
625  pauseIngress();
626  bool windowUpdateTimeout = !isEgressComplete() && isExpectingWindowUpdate();
627  if (handler_) {
628  if (windowUpdateTimeout) {
630  folly::to<std::string>("ingress timeout, streamID=", id_));
631  ex.setProxygenError(kErrorWriteTimeout);
632  // This is a protocol error
633  ex.setCodecStatusCode(ErrorCode::PROTOCOL_ERROR);
634  onError(ex);
635  } else {
636  HTTPException ex(HTTPException::Direction::INGRESS,
637  folly::to<std::string>("ingress timeout, streamID=", id_));
638  ex.setProxygenError(kErrorTimeout);
639  onError(ex);
640  }
641  } else {
644  }
645 }
void onError(const HTTPException &error)
HTTPCodec::StreamID id_
bool isExpectingWindowUpdate() const
g_t g(f_t)
void proxygen::HTTPTransaction::onIngressTrailers ( std::unique_ptr< HTTPHeaders trailers)

Invoked by the session when the ingress trailers have been parsed.

Definition at line 362 of file HTTPTransaction.cpp.

References checkCreateDeferredIngress(), deferredIngress_, id_, folly::gen::move, mustQueueIngress(), processIngressTrailers(), proxygen::HTTPEvent::TRAILERS_COMPLETE, and validateIngressStateTransition().

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

362  {
364  HTTPTransactionIngressSM::Event::onTrailers)) {
365  return;
366  }
367  if (mustQueueIngress()) {
370  std::move(trailers));
371  VLOG(4) << "Queued ingress event of type "
372  << HTTPEvent::Type::TRAILERS_COMPLETE << " " << *this;
373  } else {
375  }
376 }
HTTPCodec::StreamID id_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
void processIngressTrailers(std::unique_ptr< HTTPHeaders > trailers)
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
void proxygen::HTTPTransaction::onIngressUpgrade ( UpgradeProtocol  protocol)

Invoked by the session when the session and transaction need to be upgraded to a different protocol

Definition at line 389 of file HTTPTransaction.cpp.

References checkCreateDeferredIngress(), deferredIngress_, id_, mustQueueIngress(), processIngressUpgrade(), proxygen::HTTPEvent::UPGRADE, and validateIngressStateTransition().

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

389  {
391  HTTPTransactionIngressSM::Event::onUpgrade)) {
392  return;
393  }
394  if (mustQueueIngress()) {
396  deferredIngress_->emplace(id_, HTTPEvent::Type::UPGRADE, protocol);
397  VLOG(4) << "Queued ingress event of type " << HTTPEvent::Type::UPGRADE
398  << " " << *this;
399  } else {
400  processIngressUpgrade(protocol);
401  }
402 }
HTTPCodec::StreamID id_
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
void processIngressUpgrade(UpgradeProtocol protocol)
void proxygen::HTTPTransaction::onIngressWindowUpdate ( uint32_t  amount)

Invoked by the session when the remote endpoint of this transaction signals that it has consumed 'amount' bytes. This is only for versions of HTTP that support per transaction flow control.

Definition at line 647 of file HTTPTransaction.cpp.

References proxygen::ERROR, proxygen::FLOW_CONTROL_ERROR, proxygen::Window::free(), g(), proxygen::Window::getCapacity(), proxygen::Window::getOutstanding(), notifyTransportPendingEgress(), sendAbort(), sendWindow_, updateReadTimeout(), and useFlowControl_.

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

647  {
648  if (!useFlowControl_) {
649  return;
650  }
651  DestructorGuard g(this);
652  VLOG(4) << "Remote side ack'd " << amount << " bytes " << *this ;
654  if (sendWindow_.free(amount)) {
656  } else {
657  LOG(ERROR) << "sendWindow_.free failed with amount=" << amount
658  << " capacity=" << sendWindow_.getCapacity()
659  << " outstanding=" << sendWindow_.getOutstanding()
660  << " " << *this;
662  }
663 }
uint32_t getCapacity() const
Definition: Window.cpp:32
uint32_t getOutstanding() const
Definition: Window.cpp:37
g_t g(f_t)
bool free(uint32_t amount)
Definition: Window.cpp:63
void proxygen::HTTPTransaction::onPriorityUpdate ( const http2::PriorityUpdate priority)

Notify of priority change, will not generate a PRIORITY frame

Definition at line 1374 of file HTTPTransaction.cpp.

References currentDepth_, egressQueue_, priority_, priorityFallback_, queueHandle_, proxygen::http2::PriorityUpdate::streamDependency, and proxygen::HTTP2PriorityQueueBase::updatePriority().

Referenced by updateAndSendPriority().

1374  {
1375  priority_ = priority;
1376 
1378  queueHandle_,
1379  priority_,
1380  &currentDepth_);
1381  if(priority_.streamDependency != 0 && currentDepth_ == 1) {
1382  priorityFallback_ = true;
1383  }
1384 }
virtual Handle updatePriority(Handle handle, http2::PriorityUpdate pri, uint64_t *depth=nullptr)=0
http2::PriorityUpdate priority_
HTTP2PriorityQueueBase::Handle queueHandle_
HTTP2PriorityQueueBase & egressQueue_
bool proxygen::HTTPTransaction::onPushedTransaction ( HTTPTransaction txn)

Invoked by the session (upstream only) when a new pushed transaction arrives. The txn's handler will be notified and is responsible for installing a handler. If no handler is installed in the callback, the pushed transaction will be aborted.

Definition at line 1263 of file HTTPTransaction.cpp.

References assocStreamId_, g(), getHandler(), getID(), handler_, id_, proxygen::HTTPTransactionHandler::onPushedTransaction(), and pushedTransactions_.

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

1263  {
1264  DestructorGuard g(this);
1265  CHECK_EQ(*pushTxn->assocStreamId_, id_);
1266  if (!handler_) {
1267  VLOG(4) << "Cannot add a pushed txn to an unhandled txn";
1268  return false;
1269  }
1270  handler_->onPushedTransaction(pushTxn);
1271  if (!pushTxn->getHandler()) {
1272  VLOG(4) << "Failed to create a handler for push transaction";
1273  return false;
1274  }
1275  pushedTransactions_.insert(pushTxn->getID());
1276  return true;
1277 }
virtual void onPushedTransaction(HTTPTransaction *) noexcept
HTTPCodec::StreamID id_
std::set< HTTPCodec::StreamID > pushedTransactions_
g_t g(f_t)
bool proxygen::HTTPTransaction::onWriteReady ( uint32_t  maxEgress,
double  ratio 
)

Notify this transaction that it is ok to egress. Returns true if there is additional pending egress

Definition at line 801 of file HTTPTransaction.cpp.

References cumulativeRatio_, egressCalls_, g(), isEnqueued(), prioritySample_, sendDeferredBody(), and updateRelativeWeight().

Referenced by DownstreamTransactionTest::setupRequestResponseFlow().

801  {
802  DestructorGuard g(this);
803  DCHECK(isEnqueued());
804  if (prioritySample_) {
805  updateRelativeWeight(ratio);
806  }
807  cumulativeRatio_ += ratio;
808  egressCalls_++;
809  sendDeferredBody(maxEgress);
810  return isEnqueued();
811 }
size_t sendDeferredBody(uint32_t maxEgress)
std::unique_ptr< PrioritySample > prioritySample_
void updateRelativeWeight(double ratio)
g_t g(f_t)
HTTPTransaction& proxygen::HTTPTransaction::operator= ( const HTTPTransaction )
privatedelete
void proxygen::HTTPTransaction::pauseEgress ( )

Pause egress generation. HTTPTransaction may call its Handler's onEgressPaused() method if there is a state change as a result of this call.

On receiving onEgressPaused(), the Handler should make a best effort to stop invoking the HTTPTransaction's egress generating methods. If the Handler does invoke any of those methods while the transaction is paused, however, the transaction will forward them anyway, unless it is a body event. If flow control is enabled, body events will be buffered for later transmission when egress is unpaused.

Definition at line 1150 of file HTTPTransaction.cpp.

References egressPaused_, g(), and updateHandlerPauseState().

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

1150  {
1151  VLOG(4) << "asked to pause egress " << *this ;
1152  DestructorGuard g(this);
1153  if (egressPaused_) {
1154  VLOG(4) << "egress already paused " << *this ;
1155  return;
1156  }
1157  egressPaused_ = true;
1159 }
g_t g(f_t)
void proxygen::HTTPTransaction::pauseIngress ( )
virtual

Pause ingress processing. Upon pause, the HTTPTransaction will call its Transport's pauseIngress() method. The Transport should make a best effort to stop invoking the HTTPTransaction's onIngress* callbacks. If the Transport does invoke any of those methods while the transaction is paused, however, the transaction will queue the ingress events and data and delay delivery to the Handler until the transaction is unpaused.

Definition at line 1072 of file HTTPTransaction.cpp.

References folly::HHWheelTimer::Callback::cancelTimeout(), g(), ingressPaused_, proxygen::HTTPTransaction::Transport::pauseIngress(), and transport_.

Referenced by ProxyService::ProxyHandler::onEgressPaused(), onIngressTimeout(), proxygen::RequestHandlerAdaptor::pauseIngress(), and TEST_F().

1072  {
1073  VLOG(4)<< "pauseIngress request " << *this;
1074  DestructorGuard g(this);
1075  if (ingressPaused_) {
1076  VLOG(4) << "can't pause ingress; ingressPaused=" << ingressPaused_;
1077  return;
1078  }
1079  ingressPaused_ = true;
1080  cancelTimeout();
1081  transport_.pauseIngress(this);
1082 }
virtual void pauseIngress(HTTPTransaction *txn) noexcept=0
g_t g(f_t)
void proxygen::HTTPTransaction::processIngressBody ( std::unique_ptr< folly::IOBuf chain,
size_t  len 
)
private

Definition at line 280 of file HTTPTransaction.cpp.

References aborted_, flushWindowUpdate(), FOLLY_SCOPED_TRACE_SECTION, g(), proxygen::Window::getCapacity(), handler_, proxygen::HTTPTransaction::Transport::isDraining(), isIngressComplete(), isIngressEOMSeen(), folly::gen::move, proxygen::HTTPTransaction::Transport::notifyIngressBodyProcessed(), proxygen::HTTPTransactionHandler::onBody(), recvToAck_, recvWindow_, refreshTimeout(), transport_, uint32_t, and useFlowControl_.

Referenced by onIngressBody(), and resumeIngress().

280  {
281  FOLLY_SCOPED_TRACE_SECTION("HTTPTransaction - processIngressBody");
282  DestructorGuard g(this);
283  if (aborted_) {
284  return;
285  }
286  refreshTimeout();
288  if (handler_) {
289  if (!isIngressComplete()) {
290  handler_->onBody(std::move(chain));
291  }
292 
293  if (useFlowControl_ && !isIngressEOMSeen()) {
294  recvToAck_ += len;
295  if (recvToAck_ > 0) {
296  uint32_t divisor = 2;
297  if (transport_.isDraining()) {
298  // only send window updates for draining transports when window is
299  // closed
300  divisor = 1;
301  }
302  if (uint32_t(recvToAck_) >= (recvWindow_.getCapacity() / divisor)) {
304  }
305  }
306  } // else don't care about window updates
307  }
308 }
#define FOLLY_SCOPED_TRACE_SECTION(arg,...)
uint32_t getCapacity() const
Definition: Window.cpp:32
virtual bool isDraining() const =0
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual void onBody(std::unique_ptr< folly::IOBuf > chain) noexcept=0
virtual void notifyIngressBodyProcessed(uint32_t bytes) noexcept=0
g_t g(f_t)
void proxygen::HTTPTransaction::processIngressChunkComplete ( )
private

Definition at line 351 of file HTTPTransaction.cpp.

References aborted_, g(), handler_, isIngressComplete(), proxygen::HTTPTransactionHandler::onChunkComplete(), and refreshTimeout().

Referenced by onIngressChunkComplete(), and resumeIngress().

351  {
352  DestructorGuard g(this);
353  if (aborted_) {
354  return;
355  }
356  refreshTimeout();
357  if (handler_ && !isIngressComplete()) {
359  }
360 }
virtual void onChunkComplete() noexcept
g_t g(f_t)
void proxygen::HTTPTransaction::processIngressChunkHeader ( size_t  length)
private

Definition at line 325 of file HTTPTransaction.cpp.

References aborted_, g(), handler_, isIngressComplete(), proxygen::HTTPTransactionHandler::onChunkHeader(), and refreshTimeout().

Referenced by onIngressChunkHeader(), and resumeIngress().

325  {
326  DestructorGuard g(this);
327  if (aborted_) {
328  return;
329  }
330  refreshTimeout();
331  if (handler_ && !isIngressComplete()) {
332  handler_->onChunkHeader(length);
333  }
334 }
virtual void onChunkHeader(size_t) noexcept
g_t g(f_t)
void proxygen::HTTPTransaction::processIngressEOM ( )
private

Definition at line 458 of file HTTPTransaction.cpp.

References aborted_, g(), handler_, isIngressComplete(), markEgressComplete(), proxygen::HTTPTransactionHandler::onEOM(), updateReadTimeout(), and validateIngressStateTransition().

Referenced by onIngressEOM(), and resumeIngress().

458  {
459  DestructorGuard g(this);
460  if (aborted_) {
461  return;
462  }
463  VLOG(4) << "ingress EOM on " << *this;
464  const bool wasComplete = isIngressComplete();
466  HTTPTransactionIngressSM::Event::eomFlushed)) {
467  return;
468  }
469  if (handler_) {
470  if (!wasComplete) {
471  handler_->onEOM();
472  }
473  } else {
475  }
477 }
bool validateIngressStateTransition(HTTPTransactionIngressSM::Event)
virtual void onEOM() noexcept=0
g_t g(f_t)
void proxygen::HTTPTransaction::processIngressHeadersComplete ( std::unique_ptr< HTTPMessage msg)
private

Definition at line 205 of file HTTPTransaction.cpp.

References aborted_, g(), handler_, isIngressComplete(), folly::gen::move, proxygen::HTTPTransactionHandler::onHeadersComplete(), and refreshTimeout().

Referenced by onIngressHeadersComplete(), and resumeIngress().

206  {
207  DestructorGuard g(this);
208  if (aborted_) {
209  return;
210  }
211  refreshTimeout();
212  if (handler_ && !isIngressComplete()) {
214  }
215 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual void onHeadersComplete(std::unique_ptr< HTTPMessage > msg) noexcept=0
g_t g(f_t)
void proxygen::HTTPTransaction::processIngressTrailers ( std::unique_ptr< HTTPHeaders trailers)
private

Definition at line 378 of file HTTPTransaction.cpp.

References aborted_, g(), handler_, isIngressComplete(), folly::gen::move, proxygen::HTTPTransactionHandler::onTrailers(), and refreshTimeout().

Referenced by onIngressTrailers(), and resumeIngress().

378  {
379  DestructorGuard g(this);
380  if (aborted_) {
381  return;
382  }
383  refreshTimeout();
384  if (handler_ && !isIngressComplete()) {
385  handler_->onTrailers(std::move(trailers));
386  }
387 }
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
g_t g(f_t)
virtual void onTrailers(std::unique_ptr< HTTPHeaders > trailers) noexcept=0
void proxygen::HTTPTransaction::processIngressUpgrade ( UpgradeProtocol  protocol)
private

Definition at line 404 of file HTTPTransaction.cpp.

References aborted_, g(), handler_, isIngressComplete(), and proxygen::HTTPTransactionHandler::onUpgrade().

Referenced by onIngressUpgrade(), and resumeIngress().

404  {
405  DestructorGuard g(this);
406  if (aborted_) {
407  return;
408  }
409  if (handler_ && !isIngressComplete()) {
410  handler_->onUpgrade(protocol);
411  }
412 }
virtual void onUpgrade(UpgradeProtocol protocol) noexcept=0
g_t g(f_t)
void proxygen::HTTPTransaction::rateLimitTimeoutExpired ( )
private
void proxygen::HTTPTransaction::refreshTimeout ( )
inline

Schedule or refresh the timeout for this transaction

Definition at line 1100 of file HTTPTransaction.h.

References timer_.

Referenced by HTTPTransaction(), processIngressBody(), processIngressChunkComplete(), processIngressChunkHeader(), processIngressHeadersComplete(), processIngressTrailers(), proxygen::RequestHandlerAdaptor::refreshTimeout(), setIdleTimeout(), and updateReadTimeout().

1100  {
1101  if (timer_ && hasIdleTimeout()) {
1103  }
1104  }
void scheduleTimeout(Callback *callback, std::chrono::milliseconds timeout)
folly::HHWheelTimer * timer_
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268
folly::Optional< std::chrono::milliseconds > transactionTimeout_
void proxygen::HTTPTransaction::removeExTransaction ( HTTPCodec::StreamID  exStreamId)
inline

Remove the exTxn ID from the control stream txn.

Definition at line 1093 of file HTTPTransaction.h.

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

1093  {
1094  exTransactions_.erase(exStreamId);
1095  }
std::set< HTTPCodec::StreamID > exTransactions_
void proxygen::HTTPTransaction::removePushedTransaction ( HTTPCodec::StreamID  pushStreamId)
inline

Remove the pushed txn ID from the set of pushed txns associated with this txn.

Definition at line 1086 of file HTTPTransaction.h.

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

1086  {
1087  pushedTransactions_.erase(pushStreamId);
1088  }
std::set< HTTPCodec::StreamID > pushedTransactions_
virtual void proxygen::HTTPTransaction::removeWaitingForReplaySafety ( folly::AsyncTransport::ReplaySafetyCallback callback)
inlinevirtual

Remove a callback waiting for replay protection (if it was canceled).

Definition at line 1184 of file HTTPTransaction.h.

References transport_.

1185  {
1187  }
virtual void removeWaitingForReplaySafety(folly::AsyncTransport::ReplaySafetyCallback *callback) noexcept=0
void proxygen::HTTPTransaction::reset ( bool  useFlowControl,
uint32_t  receiveInitialWindowSize,
uint32_t  receiveStreamWindowSize,
uint32_t  sendInitialWindowSize 
)

Definition at line 148 of file HTTPTransaction.cpp.

References recvWindow_, sendWindow_, proxygen::Window::setCapacity(), setReceiveWindow(), and useFlowControl_.

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

151  {
152  useFlowControl_ = useFlowControl;
153  recvWindow_.setCapacity(receiveInitialWindowSize);
154  setReceiveWindow(receiveStreamWindowSize);
155  sendWindow_.setCapacity(sendInitialWindowSize);
156 }
virtual void setReceiveWindow(uint32_t capacity)
bool setCapacity(uint32_t capacity)
Definition: Window.cpp:84
void proxygen::HTTPTransaction::resumeEgress ( )

Resume egress generation. The Handler's onEgressResumed() will not be invoked if the HTTP/2 send window is full or there is too much buffered egress data on this transaction already. In that case, once the send window is not full or the buffer usage decreases, the handler will finally get onEgressResumed().

Definition at line 1161 of file HTTPTransaction.cpp.

References egressPaused_, g(), and updateHandlerPauseState().

1161  {
1162  VLOG(4) << "asked to resume egress" << *this;
1163  DestructorGuard g(this);
1164  if (!egressPaused_) {
1165  VLOG(4) << "egress already not paused" << *this;
1166  return;
1167  }
1168  egressPaused_ = false;
1170 }
g_t g(f_t)
void proxygen::HTTPTransaction::resumeIngress ( )
virtual

Resume ingress processing. Only useful after a call to pauseIngress().

Definition at line 1084 of file HTTPTransaction.cpp.

References proxygen::HTTPEvent::BODY, proxygen::HTTPEvent::CHUNK_COMPLETE, proxygen::HTTPEvent::CHUNK_HEADER, folly::IOBuf::computeChainDataLength(), data, deferredIngress_, proxygen::Window::free(), g(), proxygen::HTTPEvent::getEvent(), proxygen::HTTPEvent::HEADERS_COMPLETE, ingressPaused_, inResume_, isIngressComplete(), maxDeferredIngress_, proxygen::HTTPEvent::MESSAGE_BEGIN, proxygen::HTTPEvent::MESSAGE_COMPLETE, folly::gen::move, processIngressBody(), processIngressChunkComplete(), processIngressChunkHeader(), processIngressEOM(), processIngressHeadersComplete(), processIngressTrailers(), processIngressUpgrade(), recvWindow_, proxygen::HTTPTransaction::Transport::resumeIngress(), folly::size(), proxygen::HTTPEvent::TRAILERS_COMPLETE, transport_, updateReadTimeout(), and proxygen::HTTPEvent::UPGRADE.

Referenced by ProxyService::ProxyHandler::onEgressResumed(), proxygen::RequestHandlerAdaptor::resumeIngress(), and TEST_F().

1084  {
1085  VLOG(4) << "resumeIngress request " << *this;
1086  DestructorGuard g(this);
1087  if (!ingressPaused_ || isIngressComplete()) {
1088  VLOG(4) << "can't resume ingress, ingressPaused=" << ingressPaused_
1089  << ", ingressComplete=" << isIngressComplete()
1090  << ", inResume_=" << inResume_ << " " << *this;
1091  return;
1092  }
1093  ingressPaused_ = false;
1094  transport_.resumeIngress(this);
1095  if (inResume_) {
1096  VLOG(4) << "skipping recursive resume loop " << *this;
1097  return;
1098  }
1099  inResume_ = true;
1100 
1101  if (deferredIngress_ && (maxDeferredIngress_ <= deferredIngress_->size())) {
1103  }
1104 
1105  // Process any deferred ingress callbacks
1106  // Note: we recheck the ingressPaused_ state because a callback
1107  // invoked by the resumeIngress() call above could have re-paused
1108  // the transaction.
1109  while (!ingressPaused_ && deferredIngress_ && !deferredIngress_->empty()) {
1110  HTTPEvent& callback(deferredIngress_->front());
1111  VLOG(5) << "Processing deferred ingress callback of type "
1112  << callback.getEvent() << " " << *this;
1113  switch (callback.getEvent()) {
1115  LOG(FATAL) << "unreachable";
1116  break;
1118  processIngressHeadersComplete(callback.getHeaders());
1119  break;
1120  case HTTPEvent::Type::BODY: {
1121  unique_ptr<IOBuf> data = callback.getBody();
1122  auto len = data->computeChainDataLength();
1123  CHECK(recvWindow_.free(len));
1124  processIngressBody(std::move(data), len);
1125  } break;
1127  processIngressChunkHeader(callback.getChunkLength());
1128  break;
1131  break;
1133  processIngressTrailers(callback.getTrailers());
1134  break;
1137  break;
1139  processIngressUpgrade(callback.getUpgradeProtocol());
1140  break;
1141  }
1142  if (deferredIngress_) {
1143  deferredIngress_->pop();
1144  }
1145  }
1147  inResume_ = false;
1148 }
virtual void resumeIngress(HTTPTransaction *txn) noexcept=0
void processIngressChunkHeader(size_t length)
void processIngressHeadersComplete(std::unique_ptr< HTTPMessage > msg)
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
void processIngressTrailers(std::unique_ptr< HTTPHeaders > trailers)
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
std::unique_ptr< std::queue< HTTPEvent > > deferredIngress_
std::size_t computeChainDataLength() const
Definition: IOBuf.cpp:501
g_t g(f_t)
void processIngressUpgrade(UpgradeProtocol protocol)
void processIngressBody(std::unique_ptr< folly::IOBuf > chain, size_t len)
bool free(uint32_t amount)
Definition: Window.cpp:63
static constexpr uint64_t data[1]
Definition: Fingerprint.cpp:43
void proxygen::HTTPTransaction::sendAbort ( )
virtual

Terminate the transaction. Depending on the underlying protocol, this may cause the connection to close or write egress bytes. This method does not actually write the message out on the wire immediately. All writes happen at the end of the event loop at the earliest.

This function may also cause additional callbacks such as detachTransaction() to the handler either immediately or after it returns.

Definition at line 1047 of file HTTPTransaction.cpp.

References proxygen::CANCEL, proxygen::INTERNAL_ERROR, and isUpstream().

Referenced by proxygen::HTTPSessionBase::handleErrorDirectly(), proxygen::CodecErrorResponseHandler::onError(), ProxyService::ProxyHandler::onError(), onError(), onIngressBody(), onIngressEOM(), onIngressSetSendWindow(), onIngressWindowUpdate(), proxygen::RequestHandlerAdaptor::sendAbort(), proxygen::HTTPHandlerBase::terminate(), and TEST_F().

void proxygen::HTTPTransaction::sendAbort ( ErrorCode  statusCode)
private

Implementation of sending an abort for this transaction.

Definition at line 1052 of file HTTPTransaction.cpp.

References aborted_, g(), proxygen::HTTPTransactionTransportCallback::headerBytesGenerated(), markEgressComplete(), markIngressComplete(), proxygen::HTTPTransaction::Transport::sendAbort(), folly::size(), transport_, transportCallback_, and wangle::HTTPHeaderSize::uncompressed.

1052  {
1053  DestructorGuard g(this);
1056  if (aborted_) {
1057  // This can happen in cases where the abort is sent before notifying the
1058  // handler, but its logic also wants to abort
1059  VLOG(4) << "skipping redundant abort";
1060  return;
1061  }
1062  VLOG(4) << "aborting transaction " << *this;
1063  aborted_ = true;
1064  size_t nbytes = transport_.sendAbort(this, statusCode);
1065  if (transportCallback_) {
1067  size.uncompressed = nbytes;
1069  }
1070 }
spdy::GoawayStatusCode statusCode
Definition: SPDYCodec.cpp:110
wangle::HTTPHeaderSize HTTPHeaderSize
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
virtual size_t sendAbort(HTTPTransaction *txn, ErrorCode statusCode) noexcept=0
TransportCallback * transportCallback_
g_t g(f_t)
virtual void headerBytesGenerated(HTTPHeaderSize &size) noexcept=0
void proxygen::HTTPTransaction::sendBody ( std::unique_ptr< folly::IOBuf body)
virtual

Send part or all of the egress message body to the Transport. If flow control is enabled, the chunk boundaries may not be respected. This method does not actually write the message out on the wire immediately. All writes happen at the end of the event loop at the earliest. Note: This method may be called zero or more times per message.

Parameters
bodyMessage body data; the Transport will take care of applying any necessary protocol framing, such as chunk headers.

Reimplemented in proxygen::MockHTTPTransaction.

Definition at line 784 of file HTTPTransaction.cpp.

References actualResponseLength_, folly::IOBufQueue::append(), folly::IOBuf::computeChainDataLength(), deferredEgressBody_, egressState_, folly::gen::guard(), isEnqueued(), folly::gen::move, proxygen::HTTPTransaction::Transport::notifyEgressBodyBuffered(), notifyTransportPendingEgress(), proxygen::StateMachine< T >::transit(), transport_, and folly::Optional< Value >::value().

Referenced by ProxyService::ProxyHandler::onBody(), proxygen::HTTPDirectResponseHandler::onHeadersComplete(), proxygen::RequestHandlerAdaptor::sendBody(), proxygen::HTTPHandlerBase::sendBody(), proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), CurlService::CurlClient::sendRequest(), and DownstreamTransactionTest::setupRequestResponseFlow().

784  {
785  DestructorGuard guard(this);
787  egressState_, HTTPTransactionEgressSM::Event::sendBody));
788 
789  if (body) {
790  size_t bodyLen = body->computeChainDataLength();
792 
793  if (isEnqueued()) {
795  }
796  }
799 }
void append(std::unique_ptr< folly::IOBuf > &&buf, bool pack=false)
Definition: IOBufQueue.cpp:143
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
virtual void notifyEgressBodyBuffered(int64_t bytes) noexcept=0
HTTPTransactionEgressSM::State egressState_
GuardImpl guard(ErrorHandler &&handler)
Definition: Base.h:840
std::size_t computeChainDataLength() const
Definition: IOBuf.cpp:501
folly::IOBufQueue deferredEgressBody_
folly::Optional< uint64_t > actualResponseLength_
FOLLY_CPP14_CONSTEXPR const Value & value() const &
Definition: Optional.h:268
void proxygen::HTTPTransaction::sendBodyFlowControlled ( std::unique_ptr< folly::IOBuf body = nullptr)
private
size_t proxygen::HTTPTransaction::sendBodyNow ( std::unique_ptr< folly::IOBuf body,
size_t  bodyLen,
bool  eom 
)
private

Definition at line 955 of file HTTPTransaction.cpp.

References egressLimitBytesPerMs_, egressState_, enableLastByteFlushedTracking_, proxygen::FLOW_CONTROL_ERROR, proxygen::Window::getCapacity(), proxygen::Window::getSize(), id_, proxygen::HTTPException::INGRESS_AND_EGRESS, ingressErrorSeen_, isExpectingWindowUpdate(), isPrioritySampled(), proxygen::kErrorEOF, folly::gen::move, numLimitedBytesEgressed_, onError(), proxygen::Window::reserve(), proxygen::HTTPTransaction::Transport::sendBody(), sendEOMNow(), sendWindow_, proxygen::HTTPException::setCodecStatusCode(), proxygen::Exception::setProxygenError(), string, trailers_, proxygen::StateMachine< T >::transit(), transport_, updateReadTimeout(), updateTransactionBytesSent(), and useFlowControl_.

Referenced by sendDeferredBody().

956  {
957  static const std::string noneStr = "None";
958  DCHECK(body);
959  DCHECK_GT(bodyLen, 0);
960  size_t nbytes = 0;
961  if (useFlowControl_) {
962  CHECK(sendWindow_.reserve(bodyLen));
963  }
964  VLOG(4) << "Sending " << bodyLen
965  << " bytes of body. eom=" << ((sendEom) ? "yes" : "no")
966  << " send_window is "
967  << (useFlowControl_
968  ? folly::to<std::string>(
970  : noneStr)
971  << " trailers=" << ((trailers_) ? "yes" : "no") << " " << *this;
972  if (sendEom && !trailers_) {
974  egressState_, HTTPTransactionEgressSM::Event::eomFlushed));
975  } else if (ingressErrorSeen_ && isExpectingWindowUpdate()) {
976  // I don't know how we got here but we're in trouble. We need a window
977  // update to continue but we've already seen an ingress error.
979  folly::to<std::string>("window blocked with ingress error,"
980  " streamID=", id_));
981  ex.setProxygenError(kErrorEOF);
982  ex.setCodecStatusCode(ErrorCode::FLOW_CONTROL_ERROR);
983  onError(ex);
984  return 0;
985  }
987  nbytes = transport_.sendBody(this,
988  std::move(body),
989  sendEom && !trailers_,
991  if (sendEom && trailers_) {
992  sendEOMNow();
993  }
994  if (isPrioritySampled()) {
996  }
997  if (egressLimitBytesPerMs_ > 0) {
998  numLimitedBytesEgressed_ += nbytes;
999  }
1000  return nbytes;
1001 }
void onError(const HTTPException &error)
HTTPCodec::StreamID id_
uint32_t getCapacity() const
Definition: Window.cpp:32
std::unique_ptr< HTTPHeaders > trailers_
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
int32_t getSize() const
Definition: Window.cpp:23
bool reserve(uint32_t amount, bool strict=true)
Definition: Window.cpp:41
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
void updateTransactionBytesSent(uint64_t bytes)
bool isExpectingWindowUpdate() const
HTTPTransactionEgressSM::State egressState_
virtual size_t sendBody(HTTPTransaction *txn, std::unique_ptr< folly::IOBuf >, bool eom, bool trackLastByteFlushed) noexcept=0
const char * string
Definition: Conv.cpp:212
virtual void proxygen::HTTPTransaction::sendChunkHeader ( size_t  length)
inlinevirtual

Write any protocol framing required for the subsequent call(s) to sendBody(). This method does not actually write the message out on the wire immediately. All writes happen at the end of the event loop at the earliest.

Parameters
lengthLength in bytes of the body data to follow.

Definition at line 825 of file HTTPTransaction.h.

References proxygen::StateMachine< T >::transit(), and transport_.

Referenced by proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), and proxygen::RequestHandlerAdaptor::sendChunkHeader().

825  {
827  egressState_, HTTPTransactionEgressSM::Event::sendChunkHeader));
828  // TODO: move this logic down to session/codec
830  chunkHeaders_.emplace_back(Chunk(length));
831  }
832  }
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
std::list< Chunk > chunkHeaders_
HTTPTransactionEgressSM::State egressState_
virtual const HTTPCodec & getCodec() const noexcept=0
virtual bool supportsParallelRequests() const =0
virtual void proxygen::HTTPTransaction::sendChunkTerminator ( )
inlinevirtual

Write any protocol syntax needed to terminate the data. This method does not actually write the message out on the wire immediately. All writes happen at the end of the event loop at the earliest. Frame begun by the last call to sendChunkHeader().

Definition at line 840 of file HTTPTransaction.h.

References proxygen::StateMachine< T >::transit().

Referenced by proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), and proxygen::RequestHandlerAdaptor::sendChunkTerminator().

840  {
842  egressState_, HTTPTransactionEgressSM::Event::sendChunkTerminator));
843  }
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
HTTPTransactionEgressSM::State egressState_
size_t proxygen::HTTPTransaction::sendDeferredBody ( uint32_t  maxEgress)
private

Definition at line 814 of file HTTPTransaction.cpp.

References proxygen::HTTPTransactionTransportCallback::bodyBytesGenerated(), folly::IOBufQueue::chainLength(), chunkHeaders_, deferredEgressBody_, dequeue(), proxygen::Window::getSize(), hasPendingEOM(), proxygen::HTTPTransaction::Chunk::headerSent, int32_t, isEgressEOMQueued(), proxygen::HTTPTransaction::Chunk::length, maybeDelayForRateLimit(), folly::gen::move, notifyTransportPendingEgress(), sendBodyNow(), proxygen::HTTPTransaction::Transport::sendChunkHeader(), proxygen::HTTPTransaction::Transport::sendChunkTerminator(), sendEOMNow(), sendWindow_, folly::IOBufQueue::split(), transport_, transportCallback_, uint32_t, and useFlowControl_.

Referenced by onWriteReady().

814  {
815  const int32_t windowAvailable = sendWindow_.getSize();
816  const uint32_t sendWindow = useFlowControl_ ? std::min<uint32_t>(
817  maxEgress, windowAvailable > 0 ? windowAvailable : 0) : maxEgress;
818 
819  // We shouldn't be called if we have no pending body/EOM, egress is paused, or
820  // the send window is closed
821  CHECK((deferredEgressBody_.chainLength() > 0 ||
822  isEgressEOMQueued()) &&
823  sendWindow > 0);
824 
825  const size_t bytesLeft = deferredEgressBody_.chainLength();
826 
827  size_t canSend = std::min<size_t>(sendWindow, bytesLeft);
828 
829  if (maybeDelayForRateLimit()) {
830  // Timeout will call notifyTransportPendingEgress again
831  return 0;
832  }
833 
834  size_t curLen = 0;
835  size_t nbytes = 0;
836  bool willSendEOM = false;
837 
838  if (chunkHeaders_.empty()) {
839  curLen = canSend;
840  std::unique_ptr<IOBuf> body = deferredEgressBody_.split(curLen);
841  willSendEOM = hasPendingEOM();
842  DCHECK(curLen > 0 || willSendEOM);
843  if (curLen > 0) {
844  if (willSendEOM) {
845  // we have to dequeue BEFORE sending the EOM =(
846  dequeue();
847  }
848  nbytes = sendBodyNow(std::move(body), curLen, willSendEOM);
849  willSendEOM = false;
850  } // else we got called with only a pending EOM, handled below
851  } else {
852  // This body is expliticly chunked
853  while (!chunkHeaders_.empty() && canSend > 0) {
854  Chunk& chunk = chunkHeaders_.front();
855  if (!chunk.headerSent) {
856  nbytes += transport_.sendChunkHeader(this, chunk.length);
857  chunk.headerSent = true;
858  }
859  curLen = std::min<size_t>(chunk.length, canSend);
860  std::unique_ptr<folly::IOBuf> cur = deferredEgressBody_.split(curLen);
861  VLOG(4) << "sending " << curLen << " fin=false";
862  nbytes += sendBodyNow(std::move(cur), curLen, false);
863  canSend -= curLen;
864  chunk.length -= curLen;
865  if (chunk.length == 0) {
866  nbytes += transport_.sendChunkTerminator(this);
867  chunkHeaders_.pop_front();
868  } else {
869  DCHECK_EQ(canSend, 0);
870  }
871  }
872  willSendEOM = hasPendingEOM();
873  }
874  // Send any queued eom
875  if (willSendEOM) {
876  nbytes += sendEOMNow();
877  }
878 
879  // Update the handler's pause state
881 
882  if (transportCallback_) {
884  }
885  return nbytes;
886 }
std::unique_ptr< folly::IOBuf > split(size_t n)
Definition: IOBufQueue.h:420
size_t chainLength() const
Definition: IOBufQueue.h:492
virtual size_t sendChunkTerminator(HTTPTransaction *txn) noexcept=0
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
int32_t getSize() const
Definition: Window.cpp:23
size_t sendBodyNow(std::unique_ptr< folly::IOBuf > body, size_t bodyLen, bool eom)
std::list< Chunk > chunkHeaders_
virtual size_t sendChunkHeader(HTTPTransaction *txn, size_t length) noexcept=0
TransportCallback * transportCallback_
folly::IOBufQueue deferredEgressBody_
virtual void bodyBytesGenerated(size_t nbytes) noexcept=0
void proxygen::HTTPTransaction::sendEOM ( )
virtual

Finalize the egress message; depending on the protocol used by the Transport, this may involve sending an explicit "end of message" indicator. This method does not actually write the message out on the wire immediately. All writes happen at the end of the event loop at the earliest.

If the ingress message also is complete, the transaction may detach itself from the Handler and Transport and delete itself as part of this method.

Note: Either this method or sendAbort() should be called once per message.

Definition at line 1003 of file HTTPTransaction.cpp.

References aborted_, actualResponseLength_, proxygen::HTTPTransactionTransportCallback::bodyBytesGenerated(), folly::IOBufQueue::chainLength(), chunkHeaders_, deferredEgressBody_, egressPaused_, egressState_, proxygen::ERROR, expectedResponseLength_, g(), ingressPaused_, ingressState_, isEnqueued(), proxygen::HTTPTransaction::Transport::notifyPendingEgress(), notifyTransportPendingEgress(), sendEOMNow(), proxygen::StateMachine< T >::transit(), transport_, and transportCallback_.

Referenced by proxygen::HTTPDirectResponseHandler::onEOM(), ProxyService::ProxyHandler::onEOM(), proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), proxygen::RequestHandlerAdaptor::sendEOM(), proxygen::HTTPHandlerBase::sendEOM(), proxygen::HTTPHandlerBase::sendReplyCode(), proxygen::HTTPHandlerBase::sendReplyWithBody(), proxygen::HTTPHandlerBase::sendRequest(), CurlService::CurlClient::sendRequest(), DownstreamTransactionTest::setupRequestResponseFlow(), and TEST_F().

1003  {
1004  DestructorGuard g(this);
1006  egressState_, HTTPTransactionEgressSM::Event::sendEOM))
1007  << ", " << *this;
1010  auto errorMsg =
1011  folly::to<std::string>("Content-Length/body mismatch: expected= ",
1013  ", actual= ",
1015  LOG(ERROR) << errorMsg << " " << *this;
1016  }
1017 
1018  if (deferredEgressBody_.chainLength() == 0 && chunkHeaders_.empty()) {
1019  // there is nothing left to send, egress the EOM directly. For SPDY
1020  // this will jump the txn queue
1021  if (!isEnqueued()) {
1022  size_t nbytes = sendEOMNow();
1024  if (transportCallback_) {
1026  }
1027  } else {
1028  // If the txn is enqueued, sendDeferredBody()
1029  // should take care of sending the EOM.
1030  // This can happen for some uses of the egress queue
1031  VLOG(4) << "Queued egress EOM with no body"
1032  << "[egressState=" << egressState_ << ", "
1033  << "ingressState=" << ingressState_ << ", "
1034  << "egressPaused=" << egressPaused_ << ", "
1035  << "ingressPaused=" << ingressPaused_ << ", "
1036  << "aborted=" << aborted_ << ", "
1037  << "enqueued=" << isEnqueued() << ", "
1038  << "chainLength=" << deferredEgressBody_.chainLength() << "]"
1039  << " on " << *this;
1040  }
1041  } else {
1042  VLOG(4) << "Queued egress EOM on " << *this;
1044  }
1045 }
size_t chainLength() const
Definition: IOBufQueue.h:492
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
HTTPTransactionIngressSM::State ingressState_
std::list< Chunk > chunkHeaders_
HTTPTransactionEgressSM::State egressState_
folly::Optional< uint64_t > expectedResponseLength_
TransportCallback * transportCallback_
g_t g(f_t)
folly::IOBufQueue deferredEgressBody_
folly::Optional< uint64_t > actualResponseLength_
virtual void notifyPendingEgress() noexcept=0
virtual void bodyBytesGenerated(size_t nbytes) noexcept=0
size_t proxygen::HTTPTransaction::sendEOMNow ( )
private

Definition at line 944 of file HTTPTransaction.cpp.

References egressState_, proxygen::HTTPTransaction::Transport::sendEOM(), trailers_, proxygen::StateMachine< T >::transit(), and transport_.

Referenced by sendBodyNow(), sendDeferredBody(), and sendEOM().

944  {
945  VLOG(4) << "egress EOM on " << *this;
946  // TODO: with ByteEvent refactor, we will have to delay changing this
947  // state until later
949  egressState_, HTTPTransactionEgressSM::Event::eomFlushed));
950  size_t nbytes = transport_.sendEOM(this, trailers_.get());
951  trailers_.reset();
952  return nbytes;
953 }
std::unique_ptr< HTTPHeaders > trailers_
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
HTTPTransactionEgressSM::State egressState_
virtual size_t sendEOM(HTTPTransaction *txn, const HTTPHeaders *trailers) noexcept=0
void proxygen::HTTPTransaction::sendHeaders ( const HTTPMessage headers)
virtual

Send the egress message headers to the Transport. This method does not actually write the message out on the wire immediately. All writes happen at the end of the event loop at the earliest. Note: This method should be called once per message unless the first headers sent indicate a 1xx status.

sendHeaders will not set EOM flag in header frame, whereas sendHeadersWithEOM will. sendHeadersWithOptionalEOM backs both of them.

Parameters
headersMessage headers

Definition at line 780 of file HTTPTransaction.cpp.

References sendHeadersWithOptionalEOM().

Referenced by proxygen::HTTPDirectResponseHandler::onHeadersComplete(), proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), proxygen::HTTPHandlerBase::sendHeaders(), proxygen::RequestHandlerAdaptor::sendHeaders(), proxygen::MockHTTPPushHandler::sendPushHeaders(), proxygen::HTTPHandlerBase::sendRequest(), CurlService::CurlClient::sendRequest(), and DownstreamTransactionTest::setupRequestResponseFlow().

780  {
781  sendHeadersWithOptionalEOM(header, false);
782 }
virtual void sendHeadersWithOptionalEOM(const HTTPMessage &headers, bool eom)
void proxygen::HTTPTransaction::sendHeadersWithEOM ( const HTTPMessage headers)
virtual

Definition at line 776 of file HTTPTransaction.cpp.

References sendHeadersWithOptionalEOM().

776  {
777  sendHeadersWithOptionalEOM(header, true);
778 }
virtual void sendHeadersWithOptionalEOM(const HTTPMessage &headers, bool eom)
void proxygen::HTTPTransaction::sendHeadersWithOptionalEOM ( const HTTPMessage headers,
bool  eom 
)
virtual

Definition at line 729 of file HTTPTransaction.cpp.

References proxygen::HTTPTransactionTransportCallback::bodyBytesGenerated(), egressState_, proxygen::ERROR, expectedResponseLength_, flushWindowUpdate(), proxygen::HTTPTransaction::Transport::getCodec(), proxygen::HTTPMessage::getHeaders(), proxygen::HTTPCodec::getHPACKTableInfo(), proxygen::HTTPMessage::getMethod(), proxygen::HTTPCodec::getProtocol(), proxygen::HTTPHeaders::getSingleOrEmpty(), proxygen::HTTPMessage::getStatusCode(), proxygen::HEAD, proxygen::HTTPTransactionTransportCallback::headerBytesGenerated(), headRequest_, proxygen::HTTP_2, proxygen::HTTP_HEADER_CONTENT_LENGTH, isEgressComplete(), isPushed(), proxygen::HTTPMessage::isRequest(), proxygen::HTTPMessage::isResponse(), lastResponseStatus_, proxygen::HTTPTransaction::Transport::sendHeaders(), folly::size(), proxygen::StateMachine< T >::transit(), transport_, transportCallback_, and updateEgressHPACKTableInfo().

Referenced by sendHeaders(), and sendHeadersWithEOM().

731  {
733  egressState_, HTTPTransactionEgressSM::Event::sendHeaders));
734  DCHECK(!isEgressComplete());
735  if (!headers.isRequest() && !isPushed()) {
736  lastResponseStatus_ = headers.getStatusCode();
737  }
738  if (headers.isRequest()) {
739  headRequest_ = (headers.getMethod() == HTTPMethod::HEAD);
740  }
741 
742  if (headers.isResponse() && !headRequest_) {
743  const auto& contentLen =
744  headers.getHeaders().getSingleOrEmpty(HTTP_HEADER_CONTENT_LENGTH);
745  if (!contentLen.empty()) {
746  try {
747  expectedResponseLength_ = folly::to<uint64_t>(contentLen);
748  } catch (const folly::ConversionError& ex) {
749  LOG(ERROR) << "Invalid content-length: " << contentLen <<
750  ", ex=" << ex.what() << *this;
751  }
752  }
753  }
755  transport_.sendHeaders(this, headers, &size, eom);
756  if (transportCallback_) {
758  }
761  }
762  if (eom) {
764  egressState_, HTTPTransactionEgressSM::Event::sendEOM));
765  // trailers are supported in this case:
766  // trailers are for chunked encoding-transfer of a body
767  if (transportCallback_) {
769  }
771  egressState_, HTTPTransactionEgressSM::Event::eomFlushed));
772  }
774 }
virtual void sendHeaders(HTTPTransaction *txn, const HTTPMessage &headers, HTTPHeaderSize *size, bool eom) noexcept=0
wangle::HTTPHeaderSize HTTPHeaderSize
virtual HPACKTableInfo getHPACKTableInfo() const
Definition: HTTPCodec.h:338
virtual CodecProtocol getProtocol() const =0
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void updateEgressHPACKTableInfo(HPACKTableInfo)
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
HTTPTransactionEgressSM::State egressState_
folly::Optional< uint64_t > expectedResponseLength_
TransportCallback * transportCallback_
virtual void headerBytesGenerated(HTTPHeaderSize &size) noexcept=0
virtual const HTTPCodec & getCodec() const noexcept=0
virtual void bodyBytesGenerated(size_t nbytes) noexcept=0
virtual void proxygen::HTTPTransaction::sendTrailers ( const HTTPHeaders trailers)
inlinevirtual

Send message trailers to the Transport. This method does not actually write the message out on the wire immediately. All writes happen at the end of the event loop at the earliest. Note: This method may be called at most once per message.

Parameters
trailersMessage trailers.

Definition at line 853 of file HTTPTransaction.h.

References proxygen::StateMachine< T >::transit().

Referenced by proxygen::ResponseBuilder::send(), proxygen::HTTPHandlerBase::sendChunkedReplyWithBody(), and proxygen::HTTPHandlerBase::sendReplyWithBody().

853  {
855  egressState_, HTTPTransactionEgressSM::Event::sendTrailers));
856  trailers_.reset(new HTTPHeaders(trailers));
857  }
std::unique_ptr< HTTPHeaders > trailers_
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
HTTPTransactionEgressSM::State egressState_
void proxygen::HTTPTransaction::setEgressRateLimit ( uint64_t  bitsPerSecond)

Specify a rate limit for egressing bytes. The transaction will buffer extra bytes if doing so would cause it to go over the specified rate limit. Setting to a value of 0 will cause no rate-limiting to occur.

Definition at line 1172 of file HTTPTransaction.cpp.

References egressLimitBytesPerMs_, proxygen::getCurrentTime(), numLimitedBytesEgressed_, and startRateLimit_.

1172  {
1173  egressLimitBytesPerMs_ = bitsPerSecond / 8000;
1174  if (bitsPerSecond > 0 && egressLimitBytesPerMs_ == 0) {
1175  VLOG(4) << "ratelim: Limit too low (" << bitsPerSecond << "), ignoring";
1176  }
1179 }
proxygen::TimePoint startRateLimit_
std::chrono::time_point< ClockType > getCurrentTime()
Definition: Time.h:41
virtual void proxygen::HTTPTransaction::setHandler ( Handler handler)
inlinevirtual
void proxygen::HTTPTransaction::setIdleTimeout ( std::chrono::milliseconds  transactionTimeout)

Sets a transaction timeout value. If such a timeout was set, this timeout will be used instead of the default timeout interval configured in transactionIdleTimeouts_.

Definition at line 1295 of file HTTPTransaction.cpp.

References count, refreshTimeout(), and transactionTimeout_.

1296  {
1297  transactionTimeout_ = transactionTimeout;
1298  VLOG(4) << "HTTPTransaction: transaction timeout is set to "
1299  << std::chrono::duration_cast<std::chrono::milliseconds>(
1300  transactionTimeout)
1301  .count();
1302  refreshTimeout();
1303 }
int * count
folly::Optional< std::chrono::milliseconds > transactionTimeout_
void proxygen::HTTPTransaction::setLastByteFlushedTrackingEnabled ( bool  enabled)
inline

Definition at line 1224 of file HTTPTransaction.h.

References int32_t, statusCode, and uint32_t.

Referenced by proxygen::HTTPHandlerBase::sendBodyWithLastByteTracking().

1224  {
1226  }
void proxygen::HTTPTransaction::setPrioritySampled ( bool  sampled)

Definition at line 1495 of file HTTPTransaction.cpp.

References prioritySample_.

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

1495  {
1496  if (sampled) {
1497  prioritySample_ = std::make_unique<PrioritySample>(this);
1498  } else {
1499  prioritySample_.reset();
1500  }
1501 }
std::unique_ptr< PrioritySample > prioritySample_
void proxygen::HTTPTransaction::setReceiveWindow ( uint32_t  capacity)
virtual

Change the size of the receive window and propagate the change to the remote end using a window update.

TODO: when HTTPSession sends a SETTINGS frame indicating a different initial window, it should call this function on all its transactions.

Definition at line 1315 of file HTTPTransaction.cpp.

References flushWindowUpdate(), proxygen::Window::getCapacity(), int32_t, recvToAck_, recvWindow_, proxygen::Window::setCapacity(), and useFlowControl_.

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

1315  {
1316  // Depending on whether delta is positive or negative it will cause the
1317  // window to either increase or decrease.
1318  if (!useFlowControl_) {
1319  return;
1320  }
1321  int32_t delta = capacity - recvWindow_.getCapacity();
1322  if (delta < 0) {
1323  // For now, we're disallowing shrinking the window, since it can lead
1324  // to FLOW_CONTROL_ERRORs if there is data in flight.
1325  VLOG(4) << "Refusing to shrink the recv window";
1326  return;
1327  }
1328  if (!recvWindow_.setCapacity(capacity)) {
1329  return;
1330  }
1331  recvToAck_ += delta;
1333 }
uint32_t getCapacity() const
Definition: Window.cpp:32
bool setCapacity(uint32_t capacity)
Definition: Window.cpp:84
void proxygen::HTTPTransaction::setTransportCallback ( TransportCallback cb)
inline

Invoked by the handlers that are interested in tracking performance stats.

Definition at line 702 of file HTTPTransaction.h.

702  {
703  transportCallback_ = cb;
704  }
TransportCallback * transportCallback_
bool proxygen::HTTPTransaction::supportsPushTransactions ( ) const
inline
Returns
true iff this transaction can be used to push resources to the remote side.

Definition at line 953 of file HTTPTransaction.h.

References proxygen::DOWNSTREAM, and transport_.

953  {
956  }
const TransportDirection direction_
virtual bool supportsPushTransactions() const =0
virtual const HTTPCodec & getCodec() const noexcept=0
bool proxygen::HTTPTransaction::testAndClearActive ( )
inline

Definition at line 1116 of file HTTPTransaction.h.

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

1116  {
1117  bool ret = inActiveSet_;
1118  inActiveSet_ = false;
1119  return ret;
1120  }
bool proxygen::HTTPTransaction::testAndSetFirstByteSent ( )
inline

Tests if the first byte has already been sent, and if it hasn't yet then it marks it as sent.

Definition at line 1110 of file HTTPTransaction.h.

Referenced by proxygen::HTTPSessionBase::handleLastByteEvents().

1110  {
1111  bool ret = firstByteSent_;
1112  firstByteSent_ = true;
1113  return ret;
1114  }
bool proxygen::HTTPTransaction::testAndSetFirstHeaderByteSent ( )
inline

Tests if the very first byte of Header has already been set. If it hasn't yet, it marks it as sent.

Definition at line 1126 of file HTTPTransaction.h.

1126  {
1127  bool ret = firstHeaderByteSent_;
1128  firstHeaderByteSent_ = true;
1129  return ret;
1130  }
void proxygen::HTTPTransaction::timeoutExpired ( )
inlineoverridevirtualnoexcept

Timeout callback for this transaction. The timer is active until the ingress message is complete or terminated by error.

Implements folly::HHWheelTimer::Callback.

Definition at line 1152 of file HTTPTransaction.h.

References int8_t, and transport_.

Referenced by TEST_F().

1152  {
1154  }
virtual void transactionTimeout(HTTPTransaction *txn) noexcept=0
void proxygen::HTTPTransaction::updateAndSendPriority ( int8_t  newPriority)

Change the priority of this transaction, may generate a PRIORITY frame

Definition at line 1359 of file HTTPTransaction.cpp.

References egressQueue_, proxygen::HTTPTransaction::Transport::getCodec(), proxygen::HTTPCodec::mapPriorityToDependency(), proxygen::HTTPMessage::normalizePriority(), priority_, queueHandle_, proxygen::HTTPTransaction::Transport::sendPriority(), proxygen::http2::PriorityUpdate::streamDependency, transport_, and proxygen::HTTP2PriorityQueueBase::updatePriority().

1359  {
1360  newPriority = HTTPMessage::normalizePriority(newPriority);
1361  CHECK_GE(newPriority, 0);
1366 }
virtual Handle updatePriority(Handle handle, http2::PriorityUpdate pri, uint64_t *depth=nullptr)=0
http2::PriorityUpdate priority_
virtual StreamID mapPriorityToDependency(uint8_t) const
Definition: HTTPCodec.h:706
HTTP2PriorityQueueBase::Handle queueHandle_
virtual size_t sendPriority(HTTPTransaction *txn, const http2::PriorityUpdate &pri) noexcept=0
virtual const HTTPCodec & getCodec() const noexcept=0
static uint8_t normalizePriority(int8_t pri)
Definition: HTTPMessage.h:576
HTTP2PriorityQueueBase & egressQueue_
void proxygen::HTTPTransaction::updateAndSendPriority ( const http2::PriorityUpdate pri)

Definition at line 1368 of file HTTPTransaction.cpp.

References onPriorityUpdate(), priority_, proxygen::HTTPTransaction::Transport::sendPriority(), and transport_.

1369  {
1370  onPriorityUpdate(newPriority);
1372 }
http2::PriorityUpdate priority_
virtual size_t sendPriority(HTTPTransaction *txn, const http2::PriorityUpdate &pri) noexcept=0
void onPriorityUpdate(const http2::PriorityUpdate &priority)
void proxygen::HTTPTransaction::updateContentionsCount ( uint64_t  contentions)

Definition at line 1503 of file HTTPTransaction.cpp.

References proxygen::HTTP2PriorityQueueBase::BaseNode::calculateDepth(), prioritySample_, and queueHandle_.

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

1503  {
1504  CHECK(prioritySample_);
1505  prioritySample_->updateContentionsCount(contentions,
1506  queueHandle_->calculateDepth(false));
1507 }
virtual uint64_t calculateDepth(bool includeVirtual=true) const =0
std::unique_ptr< PrioritySample > prioritySample_
HTTP2PriorityQueueBase::Handle queueHandle_
void proxygen::HTTPTransaction::updateEgressHPACKTableInfo ( HPACKTableInfo  tableInfo)
private

Update the HPACKTableInfo (tableInfo_) struct

Definition at line 1240 of file HTTPTransaction.cpp.

References proxygen::HPACKTableInfo::egressBytesStored_, proxygen::HPACKTableInfo::egressHeadersStored_, proxygen::HPACKTableInfo::egressHeaderTableSize_, and tableInfo_.

Referenced by sendHeadersWithOptionalEOM().

1240  {
1242  tableInfo.egressHeaderTableSize_;
1244  tableInfo.egressBytesStored_;
1246  tableInfo.egressHeadersStored_;
1247 }
void proxygen::HTTPTransaction::updateHandlerPauseState ( )
private

Invokes the handler's onEgressPaused/Resumed if the handler's pause state needs updating

Definition at line 1205 of file HTTPTransaction.cpp.

References folly::IOBufQueue::chainLength(), deferredEgressBody_, egressPaused_, egressRateLimited_, flowControlPaused_, proxygen::Window::getSize(), handler_, handlerEgressPaused_, int64_t, proxygen::HTTPTransactionHandler::onEgressPaused(), proxygen::HTTPTransactionHandler::onEgressResumed(), proxygen::HTTPSessionStats::recordTransactionStalled(), sendWindow_, stats_, and useFlowControl_.

Referenced by notifyTransportPendingEgress(), pauseEgress(), and resumeEgress().

1205  {
1206  int64_t availWindow =
1208  // do not count transaction stalled if no more bytes to send,
1209  // i.e. when availWindow == 0
1210  if (useFlowControl_ && availWindow < 0 && !flowControlPaused_) {
1211  VLOG(4) << "transaction stalled by flow control" << *this;
1212  if (stats_) {
1214  }
1215  }
1216  flowControlPaused_ = useFlowControl_ && availWindow <= 0;
1217  bool handlerShouldBePaused = egressPaused_ || flowControlPaused_ ||
1219 
1220  if (handler_ && handlerShouldBePaused != handlerEgressPaused_) {
1221  if (handlerShouldBePaused) {
1222  handlerEgressPaused_ = true;
1224  } else {
1225  handlerEgressPaused_ = false;
1227  }
1228  }
1229 }
size_t chainLength() const
Definition: IOBufQueue.h:492
virtual void onEgressPaused() noexcept=0
virtual void onEgressResumed() noexcept=0
virtual void recordTransactionStalled() noexcept=0
int32_t getSize() const
Definition: Window.cpp:23
HTTPSessionStats * stats_
folly::IOBufQueue deferredEgressBody_
void proxygen::HTTPTransaction::updateIngressHPACKTableInfo ( HPACKTableInfo  tableInfo)
private

Definition at line 1231 of file HTTPTransaction.cpp.

References proxygen::HPACKTableInfo::ingressBytesStored_, proxygen::HPACKTableInfo::ingressHeadersStored_, proxygen::HPACKTableInfo::ingressHeaderTableSize_, and tableInfo_.

Referenced by onIngressHeadersComplete().

1231  {
1233  tableInfo.ingressHeaderTableSize_;
1235  tableInfo.ingressBytesStored_;
1237  tableInfo.ingressHeadersStored_;
1238 }
void proxygen::HTTPTransaction::updateReadTimeout ( )
private
void proxygen::HTTPTransaction::updateRelativeWeight ( double  ratio)

Definition at line 1509 of file HTTPTransaction.cpp.

References prioritySample_.

Referenced by onWriteReady().

1509  {
1510  CHECK(prioritySample_);
1511  prioritySample_->updateRatio(ratio);
1512 }
std::unique_ptr< PrioritySample > prioritySample_
void proxygen::HTTPTransaction::updateSessionBytesSheduled ( uint64_t  bytes)

Definition at line 1514 of file HTTPTransaction.cpp.

References egressPaused_, egressRateLimited_, firstHeaderByteSent_, flowControlPaused_, and prioritySample_.

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

1514  {
1515  CHECK(prioritySample_);
1516  // Do not accumulate session bytes utill header is sent.
1517  // Otherwise, the session bytes could be accumulated for a transaction
1518  // that is not allowed to egress yet.
1519  // Do not accumulate session bytes if transaction is paused.
1520  // On the other hand, if the transaction is part of the egress,
1521  // always accumulate the session bytes.
1522  if ((bytes && firstHeaderByteSent_ && !egressPaused_ &&
1524  || prioritySample_->isTransactionBytesScheduled()) {
1525  prioritySample_->updateSessionBytesSheduled(bytes);
1526  }
1527 }
std::unique_ptr< PrioritySample > prioritySample_
void proxygen::HTTPTransaction::updateTransactionBytesSent ( uint64_t  bytes)

Definition at line 1529 of file HTTPTransaction.cpp.

References prioritySample_.

Referenced by sendBodyNow().

1529  {
1530  CHECK(prioritySample_);
1531  if (bytes) {
1532  prioritySample_->updateTransactionBytesSent(bytes);
1533  }
1534 }
std::unique_ptr< PrioritySample > prioritySample_
bool proxygen::HTTPTransaction::validateIngressStateTransition ( HTTPTransactionIngressSM::Event  event)
private

Validates the ingress state transition. Returns false and sends an abort with PROTOCOL_ERROR if the transition fails. Otherwise it returns true.

Definition at line 517 of file HTTPTransaction.cpp.

References g(), id_, proxygen::HTTPException::INGRESS_AND_EGRESS, ingressState_, proxygen::INTERNAL_ERROR, proxygen::kErrorIngressStateTransition, onError(), proxygen::Exception::setProxygenError(), and proxygen::StateMachine< T >::transit().

Referenced by onIngressBody(), onIngressChunkComplete(), onIngressChunkHeader(), onIngressEOM(), onIngressHeadersComplete(), onIngressTrailers(), onIngressUpgrade(), and processIngressEOM().

518  {
519  DestructorGuard g(this);
520 
522  std::stringstream ss;
523  ss << "Invalid ingress state transition, state=" << ingressState_ <<
524  ", event=" << event << ", streamID=" << id_;
525  HTTPException ex(HTTPException::Direction::INGRESS_AND_EGRESS, ss.str());
526  ex.setProxygenError(kErrorIngressStateTransition);
527  ex.setCodecStatusCode(ErrorCode::INTERNAL_ERROR);
528  // This will invoke sendAbort() and also inform the handler of the
529  // error and detach the handler.
530  onError(ex);
531  return false;
532  }
533  return true;
534 }
void onError(const HTTPException &error)
HTTPCodec::StreamID id_
static bool transit(State &state, Event event)
Definition: StateMachine.h:27
HTTPTransactionIngressSM::State ingressState_
g_t g(f_t)

Member Data Documentation

folly::Optional<uint64_t> proxygen::HTTPTransaction::actualResponseLength_ {0}
private

Definition at line 1465 of file HTTPTransaction.h.

Referenced by sendBody(), and sendEOM().

folly::Optional<HTTPCodec::StreamID> proxygen::HTTPTransaction::assocStreamId_
private

ID of request transaction (for pushed txns only)

Definition at line 1416 of file HTTPTransaction.h.

Referenced by HTTPTransaction(), and onPushedTransaction().

std::list<Chunk> proxygen::HTTPTransaction::chunkHeaders_
private

Definition at line 1396 of file HTTPTransaction.h.

Referenced by sendDeferredBody(), and sendEOM().

double proxygen::HTTPTransaction::cumulativeRatio_ {0}
private

Definition at line 1451 of file HTTPTransaction.h.

Referenced by onWriteReady().

uint64_t proxygen::HTTPTransaction::currentDepth_ {0}
private

Definition at line 1450 of file HTTPTransaction.h.

Referenced by HTTPTransaction(), and onPriorityUpdate().

folly::IOBufQueue proxygen::HTTPTransaction::deferredEgressBody_ {folly::IOBufQueue::cacheChainLength()}
private

Queue to hold any body bytes to be sent out while egress to the remote is supposed to be paused.

Definition at line 1356 of file HTTPTransaction.h.

Referenced by markEgressComplete(), notifyTransportPendingEgress(), sendBody(), sendDeferredBody(), sendEOM(), and updateHandlerPauseState().

std::unique_ptr<std::queue<HTTPEvent> > proxygen::HTTPTransaction::deferredIngress_
private

Queue to hold any events that we receive from the Transaction while the ingress is supposed to be paused.

Definition at line 1348 of file HTTPTransaction.h.

Referenced by checkCreateDeferredIngress(), markIngressComplete(), mustQueueIngress(), onIngressBody(), onIngressChunkComplete(), onIngressChunkHeader(), onIngressEOM(), onIngressHeadersComplete(), onIngressTrailers(), onIngressUpgrade(), and resumeIngress().

bool proxygen::HTTPTransaction::deleting_
private

Definition at line 1474 of file HTTPTransaction.h.

Referenced by onDelayedDestroy().

const TransportDirection proxygen::HTTPTransaction::direction_
private

Definition at line 1358 of file HTTPTransaction.h.

Referenced by flushWindowUpdate().

uint64_t proxygen::HTTPTransaction::egressBufferLimit_
staticprivate

Definition at line 1484 of file HTTPTransaction.h.

uint64_t proxygen::HTTPTransaction::egressCalls_ {0}
private

Definition at line 1452 of file HTTPTransaction.h.

Referenced by onWriteReady().

uint64_t proxygen::HTTPTransaction::egressLimitBytesPerMs_ {0}
private

Definition at line 1486 of file HTTPTransaction.h.

Referenced by maybeDelayForRateLimit(), sendBodyNow(), and setEgressRateLimit().

bool proxygen::HTTPTransaction::egressPaused_
private
HTTP2PriorityQueueBase& proxygen::HTTPTransaction::egressQueue_
private

Reference to our priority queue

Definition at line 1401 of file HTTPTransaction.h.

Referenced by HTTPTransaction(), notifyTransportPendingEgress(), onPriorityUpdate(), updateAndSendPriority(), and ~HTTPTransaction().

bool proxygen::HTTPTransaction::egressRateLimited_
private
bool proxygen::HTTPTransaction::enableLastByteFlushedTracking_
private

Definition at line 1482 of file HTTPTransaction.h.

Referenced by sendBodyNow().

folly::Optional<HTTPCodec::ExAttributes> proxygen::HTTPTransaction::exAttributes_
private

Attributes of http2 Ex_HEADERS

Definition at line 1421 of file HTTPTransaction.h.

Referenced by HTTPTransaction().

folly::Optional<uint64_t> proxygen::HTTPTransaction::expectedContentLengthRemaining_
private

Definition at line 1463 of file HTTPTransaction.h.

Referenced by onIngressBody(), onIngressEOM(), and onIngressHeadersComplete().

folly::Optional<uint64_t> proxygen::HTTPTransaction::expectedResponseLength_
private

Definition at line 1464 of file HTTPTransaction.h.

Referenced by sendEOM(), and sendHeadersWithOptionalEOM().

std::set<HTTPCodec::StreamID> proxygen::HTTPTransaction::exTransactions_
private

Set of all exTransaction IDs associated with this transaction.

Definition at line 1431 of file HTTPTransaction.h.

Referenced by onExTransaction().

bool proxygen::HTTPTransaction::firstByteSent_
private

Definition at line 1475 of file HTTPTransaction.h.

bool proxygen::HTTPTransaction::firstHeaderByteSent_
private

Definition at line 1476 of file HTTPTransaction.h.

Referenced by updateSessionBytesSheduled().

bool proxygen::HTTPTransaction::flowControlPaused_
private

Definition at line 1469 of file HTTPTransaction.h.

Referenced by updateHandlerPauseState(), and updateSessionBytesSheduled().

bool proxygen::HTTPTransaction::handlerEgressPaused_
private

Definition at line 1470 of file HTTPTransaction.h.

Referenced by updateHandlerPauseState().

bool proxygen::HTTPTransaction::headRequest_
private

Definition at line 1481 of file HTTPTransaction.h.

Referenced by onIngressHeadersComplete(), and sendHeadersWithOptionalEOM().

bool proxygen::HTTPTransaction::inActiveSet_
private

Definition at line 1478 of file HTTPTransaction.h.

bool proxygen::HTTPTransaction::ingressErrorSeen_
private

Definition at line 1479 of file HTTPTransaction.h.

Referenced by onError(), and sendBodyNow().

bool proxygen::HTTPTransaction::ingressPaused_
private
HTTPTransactionIngressSM::State proxygen::HTTPTransaction::ingressState_
private
bool proxygen::HTTPTransaction::inResume_
private

Definition at line 1477 of file HTTPTransaction.h.

Referenced by resumeIngress().

uint64_t proxygen::HTTPTransaction::insertDepth_ {0}
private

Information about this transaction's priority.

insertDepth_ is the depth of this node in the tree when the txn was created currentDepth_ is the depth of this node in the tree after the last onPriorityUpdate. It may not reflect its real position in realtime, since after the last onPriorityUpdate, it may get reparented as parent transactions complete. cumulativeRatio_ / egressCalls_ is the average relative weight of this txn during egress

Definition at line 1449 of file HTTPTransaction.h.

Referenced by HTTPTransaction().

uint16_t proxygen::HTTPTransaction::lastResponseStatus_ {0}
private

If this transaction represents a request (ie, it is backed by an HTTPUpstreamSession) , this field indicates the last response status received from the server. If this transaction represents a response, this field indicates the last status we've sent. For instances, this could take on multiple 1xx values, and then take on 200.

Definition at line 1461 of file HTTPTransaction.h.

Referenced by onIngressHeadersComplete(), and sendHeadersWithOptionalEOM().

uint32_t proxygen::HTTPTransaction::maxDeferredIngress_ {0}
private

Definition at line 1350 of file HTTPTransaction.h.

Referenced by resumeIngress().

uint64_t proxygen::HTTPTransaction::numLimitedBytesEgressed_ {0}
private

Definition at line 1488 of file HTTPTransaction.h.

Referenced by maybeDelayForRateLimit(), sendBodyNow(), and setEgressRateLimit().

uint8_t proxygen::HTTPTransaction::pendingByteEvents_ {0}
private

Definition at line 1462 of file HTTPTransaction.h.

Referenced by onDelayedDestroy().

http2::PriorityUpdate proxygen::HTTPTransaction::priority_
private

Priority of this transaction

Definition at line 1436 of file HTTPTransaction.h.

Referenced by onPriorityUpdate(), and updateAndSendPriority().

bool proxygen::HTTPTransaction::priorityFallback_
private

Definition at line 1480 of file HTTPTransaction.h.

Referenced by HTTPTransaction(), and onPriorityUpdate().

std::unique_ptr<PrioritySample> proxygen::HTTPTransaction::prioritySample_
private
std::set<HTTPCodec::StreamID> proxygen::HTTPTransaction::pushedTransactions_
private

Set of all push transactions IDs associated with this transaction.

Definition at line 1426 of file HTTPTransaction.h.

Referenced by onPushedTransaction().

HTTP2PriorityQueueBase::Handle proxygen::HTTPTransaction::queueHandle_
private

Handle to our position in the priority queue.

Definition at line 1406 of file HTTPTransaction.h.

Referenced by HTTPTransaction(), notifyTransportPendingEgress(), onPriorityUpdate(), updateAndSendPriority(), updateContentionsCount(), and ~HTTPTransaction().

RateLimitCallback proxygen::HTTPTransaction::rateLimitCallback_ {*this}
private

Definition at line 1342 of file HTTPTransaction.h.

Referenced by maybeDelayForRateLimit().

int32_t proxygen::HTTPTransaction::recvToAck_ {0}
private

bytes we need to acknowledge to the remote end using a window update

Definition at line 1411 of file HTTPTransaction.h.

Referenced by flushWindowUpdate(), getRecvToAck(), onIngressBody(), processIngressBody(), and setReceiveWindow().

Window proxygen::HTTPTransaction::recvWindow_
private

The recv window and associated data. This keeps track of how many bytes we are allowed to buffer.

Definition at line 1376 of file HTTPTransaction.h.

Referenced by flushWindowUpdate(), onDelayedDestroy(), onIngressBody(), processIngressBody(), reset(), resumeIngress(), and setReceiveWindow().

Window proxygen::HTTPTransaction::sendWindow_
private

The send window and associated data. This keeps track of how many bytes we are allowed to send and have outstanding.

Definition at line 1382 of file HTTPTransaction.h.

Referenced by isExpectingWindowUpdate(), notifyTransportPendingEgress(), onIngressSetSendWindow(), onIngressWindowUpdate(), reset(), sendBodyNow(), sendDeferredBody(), and updateHandlerPauseState().

uint32_t proxygen::HTTPTransaction::seqNo_
private

Definition at line 1360 of file HTTPTransaction.h.

Referenced by onIngressHeadersComplete().

proxygen::TimePoint proxygen::HTTPTransaction::startRateLimit_
private

Definition at line 1487 of file HTTPTransaction.h.

Referenced by maybeDelayForRateLimit(), and setEgressRateLimit().

HTTPSessionStats* proxygen::HTTPTransaction::stats_ {nullptr}
private

Definition at line 1368 of file HTTPTransaction.h.

Referenced by HTTPTransaction(), updateHandlerPauseState(), and ~HTTPTransaction().

HPACKTableInfo proxygen::HTTPTransaction::tableInfo_
private
folly::HHWheelTimer* proxygen::HTTPTransaction::timer_
private

Definition at line 1495 of file HTTPTransaction.h.

Referenced by maybeDelayForRateLimit().

std::unique_ptr<HTTPHeaders> proxygen::HTTPTransaction::trailers_
private

Trailers to send, if any.

Definition at line 1389 of file HTTPTransaction.h.

Referenced by sendBodyNow(), and sendEOMNow().

folly::Optional<std::chrono::milliseconds> proxygen::HTTPTransaction::transactionTimeout_
private

Optional transaction timeout value.

Definition at line 1493 of file HTTPTransaction.h.

Referenced by setIdleTimeout().


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