proxygen
RejectConnectFilter.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 
15 
16 namespace proxygen {
17 
21 class RejectConnectFilter : public Filter {
22  public:
23  explicit RejectConnectFilter(RequestHandler* upstream): Filter(upstream) {
24  }
25 
26  void onRequest(std::unique_ptr<HTTPMessage> /*msg*/) noexcept override {
28  upstream_ = nullptr;
29 
31  }
32 
33  void onBody(std::unique_ptr<folly::IOBuf> /*body*/) noexcept override {}
34 
35  void onUpgrade(UpgradeProtocol /*protocol*/) noexcept override {}
36 
37  void onEOM() noexcept override {
38  }
39 
40  void requestComplete() noexcept override {
41  CHECK(!upstream_);
42  delete this;
43  }
44 
45  void onError(ProxygenError err) noexcept override {
46  // If onError is invoked before we forward the error
47  if (upstream_) {
48  upstream_->onError(err);
49  upstream_ = nullptr;
50  }
51 
52  delete this;
53  }
54 
55  void onEgressPaused() noexcept override {
56  }
57 
58  void onEgressResumed() noexcept override {
59  }
60 
61  // Response handler
62  void sendHeaders(HTTPMessage& /*msg*/) noexcept override {}
63 
64  void sendChunkHeader(size_t /*len*/) noexcept override {}
65 
66  void sendBody(std::unique_ptr<folly::IOBuf> /*body*/) noexcept override {}
67 
68  void sendChunkTerminator() noexcept override {
69  }
70 
71  void sendEOM() noexcept override {
72  }
73 
74  void sendAbort() noexcept override {
75  }
76 
77  void refreshTimeout() noexcept override {
78  }
79 };
80 
82  public:
83  void onServerStart(folly::EventBase* /*evb*/) noexcept override {}
84 
85  void onServerStop() noexcept override {
86  }
87 
89  noexcept override {
90 
91  if (msg->getMethod() == HTTPMethod::CONNECT) {
92  return new RejectConnectFilter(h);
93  }
94 
95  // No need to insert this filter
96  return h;
97  }
98 };
99 
100 }
void onServerStart(folly::EventBase *) noexceptoverride
void requestComplete() noexceptoverride
*than *hazptr_holder h
Definition: Hazptr.h:116
void refreshTimeout() noexceptoverride
void onBody(std::unique_ptr< folly::IOBuf >) noexceptoverride
void sendHeaders(HTTPMessage &) noexceptoverride
void sendAbort() noexceptoverride
void onError(ProxygenError err) noexceptoverride
RequestHandler * onRequest(RequestHandler *h, HTTPMessage *msg) noexceptoverride
void sendBody(std::unique_ptr< folly::IOBuf >) noexceptoverride
requires E e noexcept(noexcept(s.error(std::move(e))))
void onRequest(std::unique_ptr< HTTPMessage >) noexceptoverride
RejectConnectFilter(RequestHandler *upstream)
void sendEOM() noexceptoverride
void onEgressResumed() noexceptoverride
void sendChunkTerminator() noexceptoverride
RequestHandler * upstream_
void sendChunkHeader(size_t) noexceptoverride
void onEgressPaused() noexceptoverride
virtual void onError(ProxygenError err) noexcept=0
ResponseHandler * downstream_
void onEOM() noexceptoverride
void onUpgrade(UpgradeProtocol) noexceptoverride