proxygen
HTTPSession.h
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2015-present, Facebook, Inc.
3  * All rights reserved.
4  *
5  * This source code is licensed under the BSD-style license found in the
6  * LICENSE file in the root directory of this source tree. An additional grant
7  * of patent rights can be found in the PATENTS file in the same directory.
8  *
9  */
10 #pragma once
11 
13 #include <fizz/record/Types.h>
14 #include <folly/IntrusiveList.h>
15 #include <folly/io/IOBufQueue.h>
18 #include <folly/Optional.h>
29 #include <queue>
30 #include <set>
33 #include <vector>
35 
36 namespace proxygen {
37 
38 class HTTPSessionController;
39 class HTTPSessionStats;
40 
41 #define PROXYGEN_HTTP_SESSION_USES_BASE 1
42 
44  public HTTPSessionBase,
50  private HTTPCodec::Callback,
54  public:
55  using UniquePtr = std::unique_ptr<HTTPSession, Destructor>;
56 
59  }
60 
62  return sock_.get();
63  }
64 
65  folly::EventBase* getEventBase() const override {
66  if (sock_) {
67  return sock_->getEventBase();
68  }
69  return nullptr;
70  }
71 
72  const folly::AsyncTransportWrapper* getTransport() const override {
73  return sock_.get();
74  }
75 
76  bool hasActiveTransactions() const override {
77  return !transactions_.empty();
78  }
79 
80  uint32_t getNumOutgoingStreams() const override {
81  return outgoingStreams_;
82  }
83 
84  uint32_t getNumIncomingStreams() const override {
85  return incomingStreams_;
86  }
87 
89 
90  void setByteEventTracker(std::shared_ptr<ByteEventTracker> byteEventTracker);
91 
92  void setSessionStats(HTTPSessionStats* stats) override;
104  void setFlowControl(
105  size_t initialReceiveWindow,
106  size_t receiveStreamWindowSize,
107  size_t receiveSessionWindowSize) override;
108 
112  void setEgressSettings(const SettingsList& inSettings) override;
113 
114  bool getHTTP2PrioritiesEnabled() const override {
116  }
117 
118  void setHTTP2PrioritiesEnabled(bool enabled) override {
120  }
121 
124  }
125 
128  }
129 
131  override {
133  }
134 
135  bool getCurrentTransportInfo(wangle::TransportInfo* tinfo) override;
136 
140  void setMaxConcurrentIncomingStreams(uint32_t num) override;
141 
146  void setEgressBytesLimit(uint64_t bytesLimit);
147 
153  void startNow() override;
154 
158  size_t sendSettings() override;
159 
165  size_t sendPing() override;
166 
173 
179  override;
180 
185  size_t sendCertificateRequest(
186  std::unique_ptr<folly::IOBuf> certificateRequestContext,
187  std::vector<fizz::Extension> extensions) override;
188 
189  // public ManagedConnection methods
190  void timeoutExpired() noexcept override {
192  }
193 
194  void describe(std::ostream& os) const override;
195  bool isBusy() const override;
196  void notifyPendingShutdown() override;
197  void closeWhenIdle() override;
198  void dropConnection() override;
199  void dumpConnectionState(uint8_t loglevel) override;
200 
202  wangle::TransportInfo* tinfo) const override;
203 
204  void setHeaderCodecStats(HeaderCodec::Stats* stats) override {
205  codec_->setHeaderCodecStats(stats);
206  }
207 
208  void enableDoubleGoawayDrain() override {
210  }
211 
215  bool connCloseByRemote() override {
217  if (sock) {
218  return sock->isClosedByPeer();
219  }
220  return false;
221  }
222 
228  std::unique_ptr<SecondaryAuthManager> secondAuthManager);
229 
234 
235  protected:
260  HTTPSession(
261  const WheelTimerInstance& timeout,
265  HTTPSessionController* controller,
266  std::unique_ptr<HTTPCodec> codec,
267  const wangle::TransportInfo& tinfo,
268  InfoCallback* infoCallback);
269 
270  // thrift uses WheelTimer
271  HTTPSession(
272  folly::HHWheelTimer* transactionTimeouts,
274  const folly::SocketAddress& localAddr,
275  const folly::SocketAddress& peerAddr,
276  HTTPSessionController* controller,
277  std::unique_ptr<HTTPCodec> codec,
278  const wangle::TransportInfo& tinfo,
279  InfoCallback* infoCallback);
280 
281  ~HTTPSession() override;
282 
288  virtual void setupOnHeadersComplete(HTTPTransaction* txn,
289  HTTPMessage* msg) = 0;
290 
295  HTTPTransaction* txn) = 0;
296 
300  virtual void onHeadersSent(
301  const HTTPMessage& /* headers */,
302  bool /* codecWasReusable */) {}
303 
304  virtual bool allTransactionsStarted() const = 0;
305 
307 
314  bool withRST = false);
315 
320  std::unique_ptr<folly::IOBuf> getNextToSend(bool* cork, bool* eom);
321 
323  bool ingressEOM, bool egressEOM);
324 
325  size_t getCodecSendWindowSize() const;
326 
332  size_t sendPriorityImpl(HTTPCodec::StreamID streamID,
334 
336  std::unique_ptr<HTTPCodec> codec,
337  const std::string& protocolString);
338 
340  uint8_t) override {
341  return folly::none;
342  }
343 
347 
348  // AsyncTransportWrapper::ReadCallback methods
349  void getReadBuffer(void** buf, size_t* bufSize) override;
350  void readDataAvailable(size_t readSize) noexcept override;
351  bool isBufferMovable() noexcept override;
352  void readBufferAvailable(std::unique_ptr<folly::IOBuf>) noexcept override;
353  void processReadData();
354  void readEOF() noexcept override;
355  void readErr(
356  const folly::AsyncSocketException&) noexcept override;
357 
358  std::string getSecurityProtocol() const override {
359  return sock_->getSecurityProtocol();
360  }
361 
362  // HTTPCodec::Callback methods
363  void onMessageBegin(HTTPCodec::StreamID streamID, HTTPMessage* msg) override;
365  HTTPCodec::StreamID assocStreamID,
366  HTTPMessage* msg) override;
368  HTTPCodec::StreamID controlStream,
369  bool unidirectional,
370  HTTPMessage* msg) override;
372  std::unique_ptr<HTTPMessage> msg) override;
373  void onBody(HTTPCodec::StreamID streamID,
374  std::unique_ptr<folly::IOBuf> chain, uint16_t padding) override;
375  void onChunkHeader(HTTPCodec::StreamID stream, size_t length) override;
376  void onChunkComplete(HTTPCodec::StreamID stream) override;
378  std::unique_ptr<HTTPHeaders> trailers) override;
379  void onMessageComplete(HTTPCodec::StreamID streamID, bool upgrade) override;
380  void onError(HTTPCodec::StreamID streamID,
381  const HTTPException& error, bool newTxn) override;
382  void onAbort(HTTPCodec::StreamID streamID,
383  ErrorCode code) override;
384  void onGoaway(uint64_t lastGoodStreamID,
385  ErrorCode code,
386  std::unique_ptr<folly::IOBuf> debugData = nullptr) override;
387  void onPingRequest(uint64_t uniqueID) override;
388  void onPingReply(uint64_t uniqueID) override;
389  void onWindowUpdate(HTTPCodec::StreamID stream, uint32_t amount) override;
390  void onSettings(const SettingsList& settings) override;
391  void onSettingsAck() override;
392  void onPriority(HTTPCodec::StreamID stream,
393  const HTTPMessage::HTTPPriority&) override;
394  void onCertificateRequest(uint16_t requestId,
395  std::unique_ptr<folly::IOBuf> authRequest) override;
396  void onCertificate(uint16_t certId,
397  std::unique_ptr<folly::IOBuf> authenticator) override;
398  uint32_t numOutgoingStreams() const override {
399  return outgoingStreams_;
400  }
401  uint32_t numIncomingStreams() const override {
402  return incomingStreams_;
403  }
404 
405  // HTTPTransaction::Transport methods
406  void pauseIngress(HTTPTransaction* txn) noexcept override;
407  void resumeIngress(HTTPTransaction* txn) noexcept override;
408  void transactionTimeout(HTTPTransaction* txn) noexcept override;
409  void sendHeaders(HTTPTransaction* txn,
410  const HTTPMessage& headers,
412  bool includeEOM) noexcept override;
413  size_t sendBody(HTTPTransaction* txn, std::unique_ptr<folly::IOBuf>,
414  bool includeEOM, bool trackLastByteFlushed) noexcept override;
415  size_t sendChunkHeader(HTTPTransaction* txn,
416  size_t length) noexcept override;
417  size_t sendChunkTerminator(HTTPTransaction* txn) noexcept override;
418  size_t sendEOM(HTTPTransaction* txn,
419  const HTTPHeaders* trailers) noexcept override;
420  size_t sendAbort(HTTPTransaction* txn,
421  ErrorCode statusCode) noexcept override;
422  size_t sendPriority(HTTPTransaction* txn,
423  const http2::PriorityUpdate& pri) noexcept override;
424  void detach(HTTPTransaction* txn) noexcept override;
425  size_t sendWindowUpdate(HTTPTransaction* txn,
426  uint32_t bytes) noexcept override;
427  void notifyPendingEgress() noexcept override;
428  void notifyIngressBodyProcessed(uint32_t bytes) noexcept override;
429  void notifyEgressBodyBuffered(int64_t bytes) noexcept override;
431  HTTPCodec::StreamID assocStreamId,
432  HTTPTransaction::PushHandler* handler) noexcept override;
434  HTTPTransaction::Handler* handler,
435  HTTPCodec::StreamID controlStream,
436  bool unidirectional = false) noexcept override;
437 
438  const HTTPCodec& getCodec() const noexcept override {
439  return codec_.getChainEnd();
440  }
441 
447  const noexcept override {
448  return sock_.get();
449  }
450 
455  bool isDraining() const override { return draining_; }
456 
464  void drain() override;
465 
476  void shutdownTransport(bool shutdownReads = true,
477  bool shutdownWrites = true,
478  const std::string& errorMsg = "");
479 
490  const std::string& errorMsg = "");
491 
492  // EventBase::LoopCallback methods
493  void runLoopCallback() noexcept override;
494 
498  void scheduleWrite();
499 
504  void updateWriteCount();
505  void updateWriteBufSize(int64_t delta);
506 
513  }
514 
518  void immediateShutdown();
519 
524  void checkForShutdown();
525 
531 
538  HTTPCodec::StreamID streamID,
539  const folly::Optional<HTTPCodec::StreamID>& assocStreamID,
540  const folly::Optional<HTTPCodec::ExAttributes>& exAttributes,
542 
544  void onWriteSuccess(uint64_t bytesWritten);
545 
547  void onWriteError(size_t bytesWritten,
548  const folly::AsyncSocketException& ex);
549 
551  void onWriteCompleted();
552 
554  void pauseReads();
555 
560  void onSessionParseError(const HTTPException& error);
561 
566  const HTTPException& error);
567 
573  void resumeReads();
574 
576  bool hasMoreWrites() const;
577 
583  template<typename... Args1, typename... Args2>
584  void invokeOnAllTransactions(void (HTTPTransaction::*fn)(Args1...),
585  Args2&&... args) {
586  DestructorGuard g(this);
587  std::vector<HTTPCodec::StreamID> ids;
588  for (const auto& txn: transactions_) {
589  ids.push_back(txn.first);
590  }
591  for (auto idit = ids.begin(); idit != ids.end() && !transactions_.empty();
592  ++idit) {
593  auto txn = findTransaction(*idit);
594  if (txn != nullptr) {
595  (txn->*fn)(std::forward<Args2>(args)...);
596  }
597  }
598  }
599 
600  void resumeTransactions();
601 
607  void errorOnAllTransactions(ProxygenError err, const std::string& errorMsg);
608 
609  void errorOnTransactionIds(const std::vector<HTTPCodec::StreamID>& ids,
610  ProxygenError err,
611  const std::string& extraErrorMsg = "");
612 
614 
619  bool shouldShutdown() const;
620 
621  void drainImpl();
622 
623  void pauseReadsImpl();
624  void resumeReadsImpl();
625 
626  bool readsUnpaused() const {
627  return reads_ == SocketState::UNPAUSED;
628  }
629 
630  bool readsPaused() const {
631  return reads_ == SocketState::PAUSED;
632  }
633 
634  bool readsShutdown() const {
635  return reads_ == SocketState::SHUTDOWN;
636  }
637 
638  bool writesUnpaused() const {
639  return writes_ == SocketState::UNPAUSED;
640  }
641 
642  bool writesPaused() const {
643  return writes_ == SocketState::PAUSED;
644  }
645 
646  bool writesShutdown() const {
647  return writes_ == SocketState::SHUTDOWN;
648  }
649 
651  if (!isLoopCallbackScheduled()) {
652  sock_->getEventBase()->runInLoop(this);
653  }
654 
655  if (shutdownTransportCb_ &&
656  !shutdownTransportCb_->isLoopCallbackScheduled()) {
657  sock_->getEventBase()->runInLoop(shutdownTransportCb_.get(), true);
658  }
659  }
660 
662  if (isLoopCallbackScheduled()) {
664  }
665  if (shutdownTransportCb_) {
666  shutdownTransportCb_->cancelLoopCallback();
667  }
668  }
669 
670  // protected members
671  class WriteTimeout :
673  public:
674  explicit WriteTimeout(HTTPSession* session) : session_(session) {}
675  ~WriteTimeout() override {}
676 
677  void timeoutExpired() noexcept override { session_->writeTimeoutExpired(); }
678  private:
680  };
682 
685 
688 
691 
692  std::map<HTTPCodec::StreamID, HTTPTransaction> transactions_;
693 
696 
698 
700 
705  unsigned numActiveWrites_{0};
706 
711  bool draining_:1;
712 
713  bool started_:1;
714 
718 
719  private:
722  }
723 
724  bool isUpstream() const;
725  bool isDownstream() const;
726 
727  // from folly::AsyncTransport::BufferCallback
728  void onEgressBuffered() override;
729  void onEgressBufferCleared() override;
730 
731  void setupCodec();
732  void onSetSendWindow(uint32_t windowSize);
733  void onSetMaxInitiatedStreams(uint32_t maxTxns);
734 
736 
738 
740 
742  const ByteEvent& lastByteEvent);
743 
748  void onConnectionSendWindowOpen() override;
749  void onConnectionSendWindowClosed() override;
750 
755 
762 
764 
765  bool isConnWindowFull() const {
767  }
768 
769  //ByteEventTracker::Callback functions
770  void onPingReplyLatency(int64_t latency) noexcept override;
772  uint64_t offset, bool eomTracked) noexcept override;
773  void onDeleteAckEvent() noexcept override;
774 
783  void commonEom(
784  HTTPTransaction* txn,
785  size_t encodedSize,
786  bool piggybacked) noexcept;
787 
801  ReplaySafetyCallback* callback) noexcept override {
802  if (sock_->isReplaySafe()) {
803  callback->onReplaySafe();
804  } else {
805  waitingForReplaySafety_.push_back(callback);
806  }
807  }
808 
814  ReplaySafetyCallback* callback) noexcept override {
815  waitingForReplaySafety_.remove(callback);
816  }
817 
822  bool needToBlockForReplaySafety() const override {
823  return !waitingForReplaySafety_.empty();
824  }
825 
830  void onReplaySafe() noexcept override;
831 
832  // Returns the number of streams that count against a pipelining limit.
833  // Upstreams can't really pipleine (send responses before requests), so
834  // count ANY stream against the limit.
835  size_t getPipelineStreamCount() const {
836  return isDownstream() ? incomingStreams_ : transactions_.size();
837  }
838 
839  bool maybeResumePausedPipelinedTransaction(size_t oldStreamCount,
840  uint32_t txnSeqn);
841 
843 
844  // private members
845 
846  std::list<ReplaySafetyCallback*> waitingForReplaySafety_;
847 
852  class WriteSegment :
854  public:
855  WriteSegment(HTTPSession* session, uint64_t length);
856 
857  void setCork(bool cork) {
858  if (cork) {
859  flags_ = flags_ | folly::WriteFlags::CORK;
860  } else {
862  }
863  }
864 
865  void setEOR(bool eor) {
866  if (eor) {
867  flags_ = flags_ | folly::WriteFlags::EOR;
868  } else {
869  unSet(flags_, folly::WriteFlags::EOR);
870  }
871  }
872 
877  void detach();
878 
880  return flags_;
881  }
882 
883  uint64_t getLength() const {
884  return length_;
885  }
886 
887  // AsyncTransport::WriteCallback methods
888  void writeSuccess() noexcept override;
889  void writeErr(
890  size_t bytesWritten,
891  const folly::AsyncSocketException&) noexcept override;
892 
894  private:
895 
899  void remove();
900 
905  };
906  using WriteSegmentList =
909 
914 
923 
929 
934 
939 
944 
949 
955 
960 
965 
966  std::shared_ptr<ByteEventTracker> byteEventTracker_{nullptr};
967 
972 
973  // Flow control settings
977 
979  public:
981  session_(session),
982  dg_(std::make_unique<DestructorGuard>(session)) { }
983 
985 
986  void runLoopCallback() noexcept override {
987  VLOG(4) << *session_ << " shutdown from onEgressMessageFinished";
988  bool shutdownReads =
990  session_->shutdownTransport(shutdownReads, true);
991  dg_.reset();
992  }
993 
994  private:
996  std::unique_ptr<DestructorGuard> dg_;
997  };
998  std::unique_ptr<ShutdownTransportCallback> shutdownTransportCb_;
999 
1001  public:
1002  explicit FlowControlTimeout(HTTPSession* session) : session_(session) {}
1003  ~FlowControlTimeout() override {}
1004 
1005  void timeoutExpired() noexcept override {
1007  }
1008 
1009  std::chrono::milliseconds getTimeoutDuration() const {
1010  return duration_;
1011  }
1012 
1013  void setTimeoutDuration(std::chrono::milliseconds duration) {
1014  duration_ = duration;
1015  }
1016  private:
1018  std::chrono::milliseconds duration_{std::chrono::milliseconds(0)};
1019  };
1021 
1023  public:
1024  explicit DrainTimeout(HTTPSession* session) : session_(session) {}
1025  ~DrainTimeout() override {}
1026 
1027  void timeoutExpired() noexcept override {
1029  }
1030  private:
1032  };
1034 
1037  PAUSED = 1,
1039  };
1040 
1043 
1049  // indicates a fatal error that prevents further ingress data processing
1051  bool inResume_:1;
1053 
1054  // secondary authentication manager
1055  std::unique_ptr<SecondaryAuthManager> secondAuthManager_;
1056 };
1057 
1058 } // proxygen
size_t sendAbort(HTTPTransaction *txn, ErrorCode statusCode) noexceptoverride
size_t sendBody(HTTPTransaction *txn, std::unique_ptr< folly::IOBuf >, bool includeEOM, bool trackLastByteFlushed) noexceptoverride
size_t getPipelineStreamCount() const
Definition: HTTPSession.h:835
bool getCurrentTransportInfo(wangle::TransportInfo *tinfo) override
bool readsUnpaused() const
Definition: HTTPSession.h:626
HTTPTransaction * createTransaction(HTTPCodec::StreamID streamID, const folly::Optional< HTTPCodec::StreamID > &assocStreamID, const folly::Optional< HTTPCodec::ExAttributes > &exAttributes, const http2::PriorityUpdate &priority=http2::DefaultPriority)
void onCertificate(uint16_t certId, std::unique_ptr< folly::IOBuf > authenticator) override
void shutdownTransport(bool shutdownReads=true, bool shutdownWrites=true, const std::string &errorMsg="")
size_t sendSettings() override
void addLastByteEvent(HTTPTransaction *txn, uint64_t byteNo) noexcept
int64_t length_
Definition: JSONSchema.cpp:233
bool onNativeProtocolUpgradeImpl(HTTPCodec::StreamID txn, std::unique_ptr< HTTPCodec > codec, const std::string &protocolString)
void invokeOnAllTransactions(void(HTTPTransaction::*fn)(Args1...), Args2 &&...args)
Definition: HTTPSession.h:584
void errorOnTransactionId(HTTPCodec::StreamID id, HTTPException ex)
folly::AsyncTransportWrapper * getTransport() override
Definition: HTTPSession.h:61
void setSessionStats(HTTPSessionStats *stats) override
size_t chainLength() const
Definition: IOBufQueue.h:492
spdy::GoawayStatusCode statusCode
Definition: SPDYCodec.cpp:110
void onPingReply(uint64_t uniqueID) override
void onPingReplyLatency(int64_t latency) noexceptoverride
void onEgressBuffered() override
HTTPCodecFilterChain codec_
HTTPTransaction * findTransaction(HTTPCodec::StreamID streamID)
void onDeleteAckEvent() noexceptoverride
void rescheduleLoopCallbacks()
Definition: HTTPSession.h:650
size_t receiveSessionWindowSize_
Definition: HTTPSession.h:976
bool isBusy() const override
void resumeIngress(HTTPTransaction *txn) noexceptoverride
void onEgressMessageFinished(HTTPTransaction *txn, bool withRST=false)
const SocketAddress peerAddr
Definition: TestUtils.cpp:20
FlowControlFilter * connFlowControl_
Definition: HTTPSession.h:913
void onNewTransactionParseError(HTTPCodec::StreamID streamID, const HTTPException &error)
void errorOnAllTransactions(ProxygenError err, const std::string &errorMsg)
std::string getSecurityProtocol() const override
Definition: HTTPSession.h:358
std::unique_ptr< folly::IOBuf > getNextToSend(bool *cork, bool *eom)
size_t getCodecSendWindowSize() const
void sendHeaders(HTTPTransaction *txn, const HTTPMessage &headers, HTTPHeaderSize *size, bool includeEOM) noexceptoverride
bool connCloseByRemote() override
Definition: HTTPSession.h:215
HTTP2PriorityQueue::NextEgressResult nextEgressResults_
Definition: HTTPSession.h:964
void readErr(const folly::AsyncSocketException &) noexceptoverride
virtual bool isClosedByPeer() const
Definition: AsyncSocket.h:571
size_t sendCertificateRequest(std::unique_ptr< folly::IOBuf > certificateRequestContext, std::vector< fizz::Extension > extensions) override
WriteTimeout writeTimeout_
Definition: HTTPSession.h:681
const T1 & getChainEnd() const
Definition: FilterChain.h:255
std::vector< std::pair< HTTPTransaction *, double >> NextEgressResult
void writeTimeoutExpired() noexcept
void onWriteError(size_t bytesWritten, const folly::AsyncSocketException &ex)
folly::IntrusiveList< WriteSegment,&WriteSegment::listHook > WriteSegmentList
Definition: HTTPSession.h:907
size_t receiveStreamWindowSize_
Definition: HTTPSession.h:975
void onPingRequest(uint64_t uniqueID) override
void onCertificateRequest(uint16_t requestId, std::unique_ptr< folly::IOBuf > authRequest) override
void dropConnection() override
bool isBufferMovable() noexceptoverride
ByteEventTracker * getByteEventTracker()
Definition: HTTPSession.h:88
bool getCurrentTransportInfoWithoutUpdate(wangle::TransportInfo *tinfo) const override
std::chrono::milliseconds getTimeoutDuration() const
Definition: HTTPSession.h:1009
virtual HTTPTransaction::Handler * getTransactionTimeoutHandler(HTTPTransaction *txn)=0
bool readsPaused() const
Definition: HTTPSession.h:630
std::unique_ptr< DestructorGuard > dg_
Definition: HTTPSession.h:996
void flowControlTimeoutExpired() noexcept
CodecFactory codec
void setNewTransactionPauseState(HTTPCodec::StreamID streamID)
STL namespace.
bool writesPaused() const
Definition: HTTPSession.h:642
void onConnectionSendWindowOpen() override
size_t sendWindowUpdate(HTTPTransaction *txn, uint32_t bytes) noexceptoverride
folly::AsyncTransportWrapper::UniquePtr sock_
Definition: HTTPSession.h:697
folly::IOBufQueue readBuf_
Definition: HTTPSession.h:687
void readTimeoutExpired() noexcept
void setMaxConcurrentIncomingStreams(uint32_t num) override
virtual void setupOnHeadersComplete(HTTPTransaction *txn, HTTPMessage *msg)=0
HTTP2PriorityQueue txnEgressQueue_
Definition: HTTPSession.h:690
static http_parser_settings settings
Definition: test.c:1529
void timeoutExpired() noexceptoverride
Definition: HTTPSession.h:190
void addAckToLastByteEvent(HTTPTransaction *txn, const ByteEvent &lastByteEvent)
uint32_t maxConcurrentIncomingStreams_
Definition: HTTPSession.h:928
void setByteEventTracker(std::shared_ptr< ByteEventTracker > byteEventTracker)
const folly::SocketAddress & getLocalAddress() const noexceptoverride
Definition: HTTPSession.h:122
requires E e noexcept(noexcept(s.error(std::move(e))))
const wangle::TransportInfo & getSetupTransportInfo() const noexceptoverride
Definition: HTTPSession.h:130
void decrementTransactionCount(HTTPTransaction *txn, bool ingressEOM, bool egressEOM)
requires And< SemiMovable< VN >... > &&SemiMovable< E > auto error(E e)
Definition: error.h:48
void startNow() override
void onSetSendWindow(uint32_t windowSize)
uint32_t maxConcurrentOutgoingStreamsRemote_
Definition: HTTPSession.h:922
void removeWaitingForReplaySafety(ReplaySafetyCallback *callback) noexceptoverride
Definition: HTTPSession.h:813
size_t sendPing() override
bool writesUnpaused() const
Definition: HTTPSession.h:638
bool isUpstream() const
const folly::SocketAddress & getPeerAddress() const noexceptoverride
Definition: HTTPSession.h:126
const folly::AsyncTransportWrapper * getUnderlyingTransport() const noexceptoverride
Definition: HTTPSession.h:446
void commonEom(HTTPTransaction *txn, size_t encodedSize, bool piggybacked) noexcept
bool maybeResumePausedPipelinedTransaction(size_t oldStreamCount, uint32_t txnSeqn)
WheelTimerInstance timeout_
Definition: HTTPSession.h:699
WriteSegmentList pendingWrites_
Definition: HTTPSession.h:908
std::unique_ptr< ShutdownTransportCallback > shutdownTransportCb_
Definition: HTTPSession.h:998
void notifyIngressBodyProcessed(uint32_t bytes) noexceptoverride
void onSetMaxInitiatedStreams(uint32_t maxTxns)
void handler(int, siginfo_t *, void *)
void readEOF() noexceptoverride
uint64_t bodyBytesPerWriteBuf_
Definition: HTTPSession.h:959
bool getHTTP2PrioritiesEnabled() const override
Definition: HTTPSession.h:114
HTTPCodec::StreamID getGracefulGoawayAck() const
bool isLoopCallbackScheduled() const
Definition: EventBase.h:160
void setHeaderCodecStats(HeaderCodec::Stats *stats) override
Definition: HTTPSession.h:204
uint32_t numIncomingStreams() const override
Definition: HTTPSession.h:401
constexpr auto size(C const &c) -> decltype(c.size())
Definition: Access.h:45
void notifyPendingEgress() noexceptoverride
void onSettingsAck() override
void setTimeoutDuration(std::chrono::milliseconds duration)
Definition: HTTPSession.h:1013
virtual bool getHTTP2PrioritiesEnabled() const
std::unique_ptr< AsyncTransportWrapper, Destructor > UniquePtr
virtual void onHeadersSent(const HTTPMessage &, bool)
Definition: HTTPSession.h:300
void describe(std::ostream &os) const override
int64_t pendingWriteSizeDelta_
Definition: HTTPSession.h:954
static Options cacheChainLength()
Definition: IOBufQueue.h:83
void onWindowUpdate(HTTPCodec::StreamID stream, uint32_t amount) override
const wangle::TransportInfo & getSetupTransportInfo() const noexcept
boost::intrusive::list_member_hook< boost::intrusive::link_mode< boost::intrusive::auto_unlink >> IntrusiveListHook
Definition: IntrusiveList.h:32
void drain() override
const HTTPCodec & getCodec() const noexceptoverride
Definition: HTTPSession.h:438
void onSettings(const SettingsList &settings) override
size_t sendEOM(HTTPTransaction *txn, const HTTPHeaders *trailers) noexceptoverride
bool isConnWindowFull() const
Definition: HTTPSession.h:765
folly::IntrusiveListHook listHook
Definition: HTTPSession.h:893
void onMessageComplete(HTTPCodec::StreamID streamID, bool upgrade) override
void setFlowControl(size_t initialReceiveWindow, size_t receiveStreamWindowSize, size_t receiveSessionWindowSize) override
const T * getUnderlyingTransport() const
HTTPTransaction * newExTransaction(HTTPTransaction::Handler *handler, HTTPCodec::StreamID controlStream, bool unidirectional=false) noexceptoverride
void addWaitingForReplaySafety(ReplaySafetyCallback *callback) noexceptoverride
Definition: HTTPSession.h:800
WriteTimeout(HTTPSession *session)
Definition: HTTPSession.h:674
http2::PriorityUpdate getMessagePriority(const HTTPMessage *msg)
void timeoutExpired() noexceptoverride
Definition: HTTPSession.h:677
void onHeadersComplete(HTTPCodec::StreamID streamID, std::unique_ptr< HTTPMessage > msg) override
bool isDraining() const override
Definition: HTTPSession.h:455
void setHTTP2PrioritiesEnabled(bool enabled)
void onConnectionSendWindowClosed() override
HTTPCodec::StreamID sendPriority(http2::PriorityUpdate pri) override
void errorOnTransactionIds(const std::vector< HTTPCodec::StreamID > &ids, ProxygenError err, const std::string &extraErrorMsg="")
void onAbort(HTTPCodec::StreamID streamID, ErrorCode code) override
bool shouldShutdown() const
void setEgressSettings(const SettingsList &inSettings) override
HTTPTransaction * newPushedTransaction(HTTPCodec::StreamID assocStreamId, HTTPTransaction::PushHandler *handler) noexceptoverride
bool readsShutdown() const
Definition: HTTPSession.h:634
void onChunkHeader(HTTPCodec::StreamID stream, size_t length) override
static const char *const value
Definition: Conv.cpp:50
bool writesShutdown() const
Definition: HTTPSession.h:646
virtual void enableDoubleGoawayDrain()
Definition: HTTPCodec.h:665
uint32_t liveTransactions_
Definition: HTTPSession.h:695
std::enable_if<!std::is_array< T >::value, std::unique_ptr< T > >::type make_unique(Args &&...args)
Definition: Memory.h:259
void runLoopCallback() noexceptoverride
void invalidStream(HTTPCodec::StreamID stream, ErrorCode code=ErrorCode::_SPDY_INVALID_STREAM)
uint32_t getMaxConcurrentOutgoingStreamsRemote() const override
Definition: HTTPSession.h:720
uint32_t numOutgoingStreams() const override
Definition: HTTPSession.h:398
const PriorityUpdate DefaultPriority
Definition: HTTP2Framer.cpp:21
std::map< HTTPCodec::StreamID, HTTPTransaction > transactions_
Definition: HTTPSession.h:692
void readDataAvailable(size_t readSize) noexceptoverride
void notifyPendingShutdown() override
size_t sendPriorityImpl(HTTPCodec::StreamID streamID, http2::PriorityUpdate pri)
std::tuple< uint32_t, bool, uint8_t > HTTPPriority
Definition: HTTPMessage.h:592
void readBufferAvailable(std::unique_ptr< folly::IOBuf >) noexceptoverride
std::vector< HTTPSetting > SettingsList
Definition: HTTPSettings.h:81
virtual folly::Optional< const HTTPMessage::HTTPPriority > getHTTPPriority(uint8_t) override
Definition: HTTPSession.h:339
void notifyEgressBodyBuffered(int64_t bytes) noexceptoverride
folly::IOBufQueue writeBuf_
Definition: HTTPSession.h:684
std::list< ReplaySafetyCallback * > waitingForReplaySafety_
Definition: HTTPSession.h:846
void getReadBuffer(void **buf, size_t *bufSize) override
void onReplaySafe() noexceptoverride
void onBody(HTTPCodec::StreamID streamID, std::unique_ptr< folly::IOBuf > chain, uint16_t padding) override
boost::intrusive::list< T, boost::intrusive::member_hook< T, IntrusiveListHook, PtrToMember >, boost::intrusive::constant_time_size< false >> IntrusiveList
Definition: IntrusiveList.h:68
virtual bool allTransactionsStarted() const =0
size_t sendChunkHeader(HTTPTransaction *txn, size_t length) noexceptoverride
void setHTTP2PrioritiesEnabled(bool enabled) override
Definition: HTTPSession.h:118
folly::EventBase * getEventBase() const override
Definition: HTTPSession.h:65
const folly::AsyncTransportWrapper * getTransport() const override
Definition: HTTPSession.h:72
void setSecondAuthManager(std::unique_ptr< SecondaryAuthManager > secondAuthManager)
void onPriority(HTTPCodec::StreamID stream, const HTTPMessage::HTTPPriority &) override
const char * string
Definition: Conv.cpp:212
WriteFlags unSet(WriteFlags a, WriteFlags b)
void timeoutExpired() noexceptoverride
Definition: HTTPSession.h:1005
bool verifyCertAuthSetting(uint32_t value)
std::shared_ptr< ByteEventTracker > byteEventTracker_
Definition: HTTPSession.h:966
g_t g(f_t)
void onSessionParseError(const HTTPException &error)
void onGoaway(uint64_t lastGoodStreamID, ErrorCode code, std::unique_ptr< folly::IOBuf > debugData=nullptr) override
void setEgressBytesLimit(uint64_t bytesLimit)
const
Definition: upload.py:398
uint64_t egressBytesLimit_
Definition: HTTPSession.h:971
size_t sendChunkTerminator(HTTPTransaction *txn) noexceptoverride
const SocketAddress localAddr
Definition: TestUtils.cpp:19
uint32_t getNumOutgoingStreams() const override
Definition: HTTPSession.h:80
void onEgressBufferCleared() override
void onMessageBegin(HTTPCodec::StreamID streamID, HTTPMessage *msg) override
uint32_t getAvailableSend() const
DrainTimeout drainTimeout_
Definition: HTTPSession.h:1033
void onChunkComplete(HTTPCodec::StreamID stream) override
uint64_t StreamID
Definition: HTTPCodec.h:49
HTTPSession(const WheelTimerInstance &timeout, folly::AsyncTransportWrapper::UniquePtr sock, const folly::SocketAddress &localAddr, const folly::SocketAddress &peerAddr, HTTPSessionController *controller, std::unique_ptr< HTTPCodec > codec, const wangle::TransportInfo &tinfo, InfoCallback *infoCallback)
uint32_t getNumIncomingStreams() const override
Definition: HTTPSession.h:84
void closeWhenIdle() override
DrainTimeout(HTTPSession *session)
Definition: HTTPSession.h:1024
std::unique_ptr< HTTPSession, Destructor > UniquePtr
Definition: HTTPSession.h:55
void updateWriteBufSize(int64_t delta)
bool hasActiveTransactions() const override
Definition: HTTPSession.h:76
virtual void setHeaderCodecStats(HeaderCodec::Stats *)
Definition: HTTPCodec.h:670
void transactionTimeout(HTTPTransaction *txn) noexceptoverride
FlowControlTimeout flowControlTimeout_
Definition: HTTPSession.h:1020
uint32_t getCertAuthSettingVal()
void detach(HTTPTransaction *txn) noexceptoverride
const folly::SocketAddress & getPeerAddress() const noexcept
void dumpConnectionState(uint8_t loglevel) override
const folly::SocketAddress & getLocalAddress() const noexcept
void timeoutExpired() noexceptoverride
Definition: HTTPSession.h:1027
SecondaryAuthManager * getSecondAuthManager() const
uint32_t streamID
Definition: SPDYCodec.cpp:131
void onTrailersComplete(HTTPCodec::StreamID streamID, std::unique_ptr< HTTPHeaders > trailers) override
void enableDoubleGoawayDrain() override
Definition: HTTPSession.h:208
void shutdownTransportWithReset(ProxygenError errorCode, const std::string &errorMsg="")
bool needToBlockForReplaySafety() const override
Definition: HTTPSession.h:822
bool isDownstream() const
std::unique_ptr< SecondaryAuthManager > secondAuthManager_
Definition: HTTPSession.h:1055
void onPushMessageBegin(HTTPCodec::StreamID streamID, HTTPCodec::StreamID assocStreamID, HTTPMessage *msg) override
void onError(HTTPCodec::StreamID streamID, const HTTPException &error, bool newTxn) override
bool hasMoreWrites() const
constexpr None none
Definition: Optional.h:87
void pauseIngress(HTTPTransaction *txn) noexceptoverride
uint64_t sessionByteOffset()
Definition: HTTPSession.h:511
HTTPSessionBase::SessionType getType() const noexceptoverride
Definition: HTTPSession.h:57
void onWriteSuccess(uint64_t bytesWritten)
void onExMessageBegin(HTTPCodec::StreamID streamID, HTTPCodec::StreamID controlStream, bool unidirectional, HTTPMessage *msg) override
void onLastByteEvent(HTTPTransaction *txn, uint64_t offset, bool eomTracked) noexceptoverride