26#ifndef ROUTER_SRC_HTTP_INCLUDE_HTTP_CLIENT_CONNECTION_H_
27#define ROUTER_SRC_HTTP_INCLUDE_HTTP_CLIENT_CONNECTION_H_
41template <
typename IOLayer>
54 CNO_CONNECTION_KIND::CNO_CLIENT,
55 use_http2 ? CNO_HTTP2 : CNO_HTTP1),
56 payload_{payload_callback},
59 initial_settings_received_{use_http2 ? false : true} {}
62 Parent::do_net_recv();
63 bool has_data =
false;
64 if (!initial_settings_received_) {
65 std::unique_lock<std::mutex>
lock(Parent::output_buffer_mutex_);
67 for (
const auto &
buffer : Parent::output_buffers_) {
74 if (!Parent::output_pending_ && has_data) {
75 Parent::output_pending_ =
true;
79 if (has_data) Parent::do_net_send();
84 if (!initial_settings_received_) {
85 initial_settings_received_ =
true;
86 payload_->on_connection_ready();
92 const char *data,
const size_t size)
override {
93 payload_->on_input_payload(data,
size);
98 [[maybe_unused]]
const cno_tail_t *tail)
override {
100 payload_->on_input_end();
101 response_received_ =
true;
106 bool send(
const uint32_t *stream_id_ptr,
const int status_code,
107 const std::string &method,
const std::string &
path,
110 response_received_ =
false;
116 if (!response_received_) {
123 const cno_message_t *msg)
override {
124 payload_->on_input_begin(msg->code,
125 std::string{msg->method.data, msg->method.size});
131 for (
const auto &header :
sequence) {
144 bool response_received_{
false};
Definition: connection_status_callbacks.h:35
Definition: connection.h:103
Definition: io_buffer.h:41
Definition: connection.h:42
bool send(const uint32_t *stream_id_ptr, const int status_code, const std::string &method, const std::string &path, const Headers &headers, const IOBuffer &data) override
Definition: connection.h:106
void start() override
Definition: connection.h:61
int on_cno_message_tail(const uint32_t session_id, const cno_tail_t *tail) override
Definition: connection.h:97
Connection(IOLayer s, base::method::Bitset *allowed_method, ConnectionStatusCallbacks *connection_handler, PayloadCallback *payload_callback, bool use_http2)
Definition: connection.h:50
int on_cno_message_body(const uint32_t session_id, const char *data, const size_t size) override
Definition: connection.h:91
PayloadCallback * payload_
Definition: connection.h:142
void on_output_buffer_empty() override
Definition: connection.h:139
int on_settings() override
Definition: connection.h:83
int on_cno_message_head(const uint32_t session_id, const cno_message_t *msg) override
Definition: connection.h:122
int on_cno_stream_end(const uint32_t id) override
Definition: connection.h:115
bool initial_settings_received_
Definition: connection.h:143
Definition: payload_callback.h:36
Definition: buffer_sequence.h:39
size_t size() const noexcept
Definition: buffer.h:120
#define HTTP_CLIENT_EXPORT
Definition: http_client_export.h:15
mysql_service_status_t send(const char *tag, const unsigned char *data, const size_t data_length) noexcept
Definition: message_service.cc:33
static char * path
Definition: mysqldump.cc:149
std::bitset< Pos::_LAST+1 > Bitset
Definition: method.h:57
Request::IOBuffer IOBuffer
Definition: request.cc:33
Request::Headers Headers
Definition: request.cc:35
std::string to_string(const T &str)
Convert CNO buffers to strings.
Definition: string.h:42
Definition: connection.h:56
size_t size(const char *const c)
Definition: base64.h:46
mutable_buffer buffer(void *p, size_t n) noexcept
Definition: buffer.h:418
Definition: gcs_xcom_synode.h:64
static std::mutex lock
Definition: net_ns.cc:56
long long sequence(UDF_INIT *initid, UDF_ARGS *args, unsigned char *, unsigned char *)
Definition: udf_example.cc:568