proxygen
Filters.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 
14 
15 namespace proxygen {
16 
29 class Filter : public RequestHandler, public ResponseHandler {
30  public:
31  explicit Filter(RequestHandler* upstream)
32  : ResponseHandler(upstream) {
33  }
34 
35  // Request handler
37  // Save downstream handler and pass ourselves as downstream handler
39  txn_ = handler->getTransaction();
41  }
42 
43  void onRequest(std::unique_ptr<HTTPMessage> headers) noexcept override {
44  upstream_->onRequest(std::move(headers));
45  }
46 
47  void onBody(std::unique_ptr<folly::IOBuf> body) noexcept override {
48  upstream_->onBody(std::move(body));
49  }
50 
51  void onUpgrade(UpgradeProtocol protocol) noexcept override {
52  upstream_->onUpgrade(protocol);
53  }
54 
55  void onEOM() noexcept override {
56  upstream_->onEOM();
57  }
58 
59  void requestComplete() noexcept override {
60  downstream_ = nullptr;
62  delete this;
63  }
64 
65  void onError(ProxygenError err) noexcept override {
66  downstream_ = nullptr;
67  upstream_->onError(err);
68  delete this;
69  }
70 
71  void onEgressPaused() noexcept override {
73  }
74 
75  void onEgressResumed() noexcept override {
77  }
78 
79  bool canHandleExpect() noexcept override {
80  return upstream_->canHandleExpect();
81  }
82 
84  return upstream_->getExHandler();
85  }
86 
87  // Response handler
88  void sendHeaders(HTTPMessage& msg) noexcept override {
90  }
91 
92  void sendChunkHeader(size_t len) noexcept override {
94  }
95 
96  void sendBody(std::unique_ptr<folly::IOBuf> body) noexcept override {
98  }
99 
100  void sendChunkTerminator() noexcept override {
102  }
103 
104  void sendEOM() noexcept override {
105  downstream_->sendEOM();
106  }
107 
108  void sendAbort() noexcept override {
110  }
111 
112  void refreshTimeout() noexcept override {
114  }
115 
116  void pauseIngress() noexcept override {
118  }
119 
120  void resumeIngress() noexcept override {
122  }
123 
126  }
127 
130  }
131 
132  void getCurrentTransportInfo(wangle::TransportInfo* tinfo) const override {
134  }
135 
136 };
137 
138 }
void sendChunkHeader(size_t len) noexceptoverride
Definition: Filters.h:92
virtual void sendChunkTerminator() noexcept=0
void sendAbort() noexceptoverride
Definition: Filters.h:108
virtual ExMessageHandler * getExHandler() noexcept
virtual void setResponseHandler(ResponseHandler *handler) noexcept
virtual void sendEOM() noexcept=0
virtual void getCurrentTransportInfo(wangle::TransportInfo *tinfo) const =0
void getCurrentTransportInfo(wangle::TransportInfo *tinfo) const override
Definition: Filters.h:132
void onError(ProxygenError err) noexceptoverride
Definition: Filters.h:65
virtual void onEOM() noexcept=0
constexpr detail::Map< Move > move
Definition: Base-inl.h:2567
virtual bool canHandleExpect() noexcept
virtual void sendChunkHeader(size_t len) noexcept=0
virtual void requestComplete() noexcept=0
HTTPTransaction * txn_
requires E e noexcept(noexcept(s.error(std::move(e))))
void onEgressPaused() noexceptoverride
Definition: Filters.h:71
virtual void sendAbort() noexcept=0
void onEOM() noexceptoverride
Definition: Filters.h:55
const wangle::TransportInfo & getSetupTransportInfo() const noexceptoverride
Definition: Filters.h:128
void requestComplete() noexceptoverride
Definition: Filters.h:59
void handler(int, siginfo_t *, void *)
virtual void resumeIngress() noexcept=0
virtual void sendHeaders(HTTPMessage &msg) noexcept=0
void onEgressResumed() noexceptoverride
Definition: Filters.h:75
void onBody(std::unique_ptr< folly::IOBuf > body) noexceptoverride
Definition: Filters.h:47
void pauseIngress() noexceptoverride
Definition: Filters.h:116
virtual void onEgressPaused() noexcept
void setResponseHandler(ResponseHandler *handler) noexceptoverride
Definition: Filters.h:36
void sendChunkTerminator() noexceptoverride
Definition: Filters.h:100
virtual void onRequest(std::unique_ptr< HTTPMessage > headers) noexcept=0
void sendEOM() noexceptoverride
Definition: Filters.h:104
void sendHeaders(HTTPMessage &msg) noexceptoverride
Definition: Filters.h:88
virtual void sendBody(std::unique_ptr< folly::IOBuf > body) noexcept=0
ExMessageHandler * getExHandler() noexceptoverride
Definition: Filters.h:83
void refreshTimeout() noexceptoverride
Definition: Filters.h:112
void resumeIngress() noexceptoverride
Definition: Filters.h:120
RequestHandler * upstream_
virtual const wangle::TransportInfo & getSetupTransportInfo() const noexcept=0
const
Definition: upload.py:398
virtual void refreshTimeout() noexcept=0
virtual void pauseIngress() noexcept=0
Filter(RequestHandler *upstream)
Definition: Filters.h:31
virtual void onUpgrade(proxygen::UpgradeProtocol prot) noexcept=0
virtual void onError(ProxygenError err) noexcept=0
ResponseHandler * downstream_
void onUpgrade(UpgradeProtocol protocol) noexceptoverride
Definition: Filters.h:51
void sendBody(std::unique_ptr< folly::IOBuf > body) noexceptoverride
Definition: Filters.h:96
virtual ResponseHandler * newPushedResponse(PushHandler *pushHandler) noexcept=0
void onRequest(std::unique_ptr< HTTPMessage > headers) noexceptoverride
Definition: Filters.h:43
virtual void onEgressResumed() noexcept
virtual void onBody(std::unique_ptr< folly::IOBuf > body) noexcept=0
bool canHandleExpect() noexceptoverride
Definition: Filters.h:79
ResponseHandler * newPushedResponse(PushHandler *handler) noexceptoverride
Definition: Filters.h:124