12c593315Sopenharmony_ci/*
22c593315Sopenharmony_ci * nghttp2 - HTTP/2 C Library
32c593315Sopenharmony_ci *
42c593315Sopenharmony_ci * Copyright (c) 2021 Tatsuhiro Tsujikawa
52c593315Sopenharmony_ci *
62c593315Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining
72c593315Sopenharmony_ci * a copy of this software and associated documentation files (the
82c593315Sopenharmony_ci * "Software"), to deal in the Software without restriction, including
92c593315Sopenharmony_ci * without limitation the rights to use, copy, modify, merge, publish,
102c593315Sopenharmony_ci * distribute, sublicense, and/or sell copies of the Software, and to
112c593315Sopenharmony_ci * permit persons to whom the Software is furnished to do so, subject to
122c593315Sopenharmony_ci * the following conditions:
132c593315Sopenharmony_ci *
142c593315Sopenharmony_ci * The above copyright notice and this permission notice shall be
152c593315Sopenharmony_ci * included in all copies or substantial portions of the Software.
162c593315Sopenharmony_ci *
172c593315Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
182c593315Sopenharmony_ci * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
192c593315Sopenharmony_ci * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
202c593315Sopenharmony_ci * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
212c593315Sopenharmony_ci * LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
222c593315Sopenharmony_ci * OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
232c593315Sopenharmony_ci * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
242c593315Sopenharmony_ci */
252c593315Sopenharmony_ci#include "shrpx_null_downstream_connection.h"
262c593315Sopenharmony_ci#include "shrpx_upstream.h"
272c593315Sopenharmony_ci#include "shrpx_downstream.h"
282c593315Sopenharmony_ci#include "shrpx_log.h"
292c593315Sopenharmony_ci
302c593315Sopenharmony_cinamespace shrpx {
312c593315Sopenharmony_ci
322c593315Sopenharmony_ciNullDownstreamConnection::NullDownstreamConnection(
332c593315Sopenharmony_ci    const std::shared_ptr<DownstreamAddrGroup> &group)
342c593315Sopenharmony_ci    : group_(group) {}
352c593315Sopenharmony_ci
362c593315Sopenharmony_ciNullDownstreamConnection::~NullDownstreamConnection() {}
372c593315Sopenharmony_ci
382c593315Sopenharmony_ciint NullDownstreamConnection::attach_downstream(Downstream *downstream) {
392c593315Sopenharmony_ci  if (LOG_ENABLED(INFO)) {
402c593315Sopenharmony_ci    DCLOG(INFO, this) << "Attaching to DOWNSTREAM:" << downstream;
412c593315Sopenharmony_ci  }
422c593315Sopenharmony_ci
432c593315Sopenharmony_ci  downstream_ = downstream;
442c593315Sopenharmony_ci
452c593315Sopenharmony_ci  return 0;
462c593315Sopenharmony_ci}
472c593315Sopenharmony_ci
482c593315Sopenharmony_civoid NullDownstreamConnection::detach_downstream(Downstream *downstream) {
492c593315Sopenharmony_ci  if (LOG_ENABLED(INFO)) {
502c593315Sopenharmony_ci    DCLOG(INFO, this) << "Detaching from DOWNSTREAM:" << downstream;
512c593315Sopenharmony_ci  }
522c593315Sopenharmony_ci  downstream_ = nullptr;
532c593315Sopenharmony_ci}
542c593315Sopenharmony_ci
552c593315Sopenharmony_ciint NullDownstreamConnection::push_request_headers() { return 0; }
562c593315Sopenharmony_ci
572c593315Sopenharmony_ciint NullDownstreamConnection::push_upload_data_chunk(const uint8_t *data,
582c593315Sopenharmony_ci                                                     size_t datalen) {
592c593315Sopenharmony_ci  return 0;
602c593315Sopenharmony_ci}
612c593315Sopenharmony_ci
622c593315Sopenharmony_ciint NullDownstreamConnection::end_upload_data() { return 0; }
632c593315Sopenharmony_ci
642c593315Sopenharmony_civoid NullDownstreamConnection::pause_read(IOCtrlReason reason) {}
652c593315Sopenharmony_ci
662c593315Sopenharmony_ciint NullDownstreamConnection::resume_read(IOCtrlReason reason,
672c593315Sopenharmony_ci                                          size_t consumed) {
682c593315Sopenharmony_ci  return 0;
692c593315Sopenharmony_ci}
702c593315Sopenharmony_ci
712c593315Sopenharmony_civoid NullDownstreamConnection::force_resume_read() {}
722c593315Sopenharmony_ci
732c593315Sopenharmony_ciint NullDownstreamConnection::on_read() { return 0; }
742c593315Sopenharmony_ci
752c593315Sopenharmony_ciint NullDownstreamConnection::on_write() { return 0; }
762c593315Sopenharmony_ci
772c593315Sopenharmony_civoid NullDownstreamConnection::on_upstream_change(Upstream *upstream) {}
782c593315Sopenharmony_ci
792c593315Sopenharmony_cibool NullDownstreamConnection::poolable() const { return false; }
802c593315Sopenharmony_ci
812c593315Sopenharmony_ciconst std::shared_ptr<DownstreamAddrGroup> &
822c593315Sopenharmony_ciNullDownstreamConnection::get_downstream_addr_group() const {
832c593315Sopenharmony_ci  return group_;
842c593315Sopenharmony_ci}
852c593315Sopenharmony_ci
862c593315Sopenharmony_ciDownstreamAddr *NullDownstreamConnection::get_addr() const { return nullptr; }
872c593315Sopenharmony_ci
882c593315Sopenharmony_ci} // namespace shrpx
89