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
NullDownstreamConnection(const std::shared_ptr<DownstreamAddrGroup> & group)32 NullDownstreamConnection::NullDownstreamConnection(
33 const std::shared_ptr<DownstreamAddrGroup> &group)
34 : group_(group) {}
35
~NullDownstreamConnection()36 NullDownstreamConnection::~NullDownstreamConnection() {}
37
attach_downstream(Downstream * downstream)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
detach_downstream(Downstream * downstream)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
push_request_headers()55 int NullDownstreamConnection::push_request_headers() { return 0; }
56
push_upload_data_chunk(const uint8_t * data,size_t datalen)57 int NullDownstreamConnection::push_upload_data_chunk(const uint8_t *data,
58 size_t datalen) {
59 return 0;
60 }
61
end_upload_data()62 int NullDownstreamConnection::end_upload_data() { return 0; }
63
pause_read(IOCtrlReason reason)64 void NullDownstreamConnection::pause_read(IOCtrlReason reason) {}
65
resume_read(IOCtrlReason reason,size_t consumed)66 int NullDownstreamConnection::resume_read(IOCtrlReason reason,
67 size_t consumed) {
68 return 0;
69 }
70
force_resume_read()71 void NullDownstreamConnection::force_resume_read() {}
72
on_read()73 int NullDownstreamConnection::on_read() { return 0; }
74
on_write()75 int NullDownstreamConnection::on_write() { return 0; }
76
on_upstream_change(Upstream * upstream)77 void NullDownstreamConnection::on_upstream_change(Upstream *upstream) {}
78
poolable() const79 bool NullDownstreamConnection::poolable() const { return false; }
80
81 const std::shared_ptr<DownstreamAddrGroup> &
get_downstream_addr_group() const82 NullDownstreamConnection::get_downstream_addr_group() const {
83 return group_;
84 }
85
get_addr() const86 DownstreamAddr *NullDownstreamConnection::get_addr() const { return nullptr; }
87
88 } // namespace shrpx
89