Upgrade to 1.46.0
[platform/upstream/nghttp2.git] / src / shrpx_null_downstream_connection.cc
1 /*
2  * nghttp2 - HTTP/2 C Library
3  *
4  * Copyright (c) 2021 Tatsuhiro Tsujikawa
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining
7  * a copy of this software and associated documentation files (the
8  * "Software"), to deal in the Software without restriction, including
9  * without limitation the rights to use, copy, modify, merge, publish,
10  * distribute, sublicense, and/or sell copies of the Software, and to
11  * permit persons to whom the Software is furnished to do so, subject to
12  * the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be
15  * included in all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
18  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
20  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
21  * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
22  * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
23  * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
24  */
25 #include "shrpx_null_downstream_connection.h"
26 #include "shrpx_upstream.h"
27 #include "shrpx_downstream.h"
28 #include "shrpx_log.h"
29
30 namespace shrpx {
31
32 NullDownstreamConnection::NullDownstreamConnection(
33     const std::shared_ptr<DownstreamAddrGroup> &group)
34     : group_(group) {}
35
36 NullDownstreamConnection::~NullDownstreamConnection() {}
37
38 int NullDownstreamConnection::attach_downstream(Downstream *downstream) {
39   if (LOG_ENABLED(INFO)) {
40     DCLOG(INFO, this) << "Attaching to DOWNSTREAM:" << downstream;
41   }
42
43   downstream_ = downstream;
44
45   return 0;
46 }
47
48 void NullDownstreamConnection::detach_downstream(Downstream *downstream) {
49   if (LOG_ENABLED(INFO)) {
50     DCLOG(INFO, this) << "Detaching from DOWNSTREAM:" << downstream;
51   }
52   downstream_ = nullptr;
53 }
54
55 int NullDownstreamConnection::push_request_headers() { return 0; }
56
57 int NullDownstreamConnection::push_upload_data_chunk(const uint8_t *data,
58                                                      size_t datalen) {
59   return 0;
60 }
61
62 int NullDownstreamConnection::end_upload_data() { return 0; }
63
64 void NullDownstreamConnection::pause_read(IOCtrlReason reason) {}
65
66 int NullDownstreamConnection::resume_read(IOCtrlReason reason,
67                                           size_t consumed) {
68   return 0;
69 }
70
71 void NullDownstreamConnection::force_resume_read() {}
72
73 int NullDownstreamConnection::on_read() { return 0; }
74
75 int NullDownstreamConnection::on_write() { return 0; }
76
77 void NullDownstreamConnection::on_upstream_change(Upstream *uptream) {}
78
79 bool NullDownstreamConnection::poolable() const { return false; }
80
81 const std::shared_ptr<DownstreamAddrGroup> &
82 NullDownstreamConnection::get_downstream_addr_group() const {
83   return group_;
84 }
85
86 DownstreamAddr *NullDownstreamConnection::get_addr() const { return nullptr; }
87
88 } // namespace shrpx