From 4aa9c8bf2bed8bcaf8970a02de520952bdcccd71 Mon Sep 17 00:00:00 2001 From: Vitaliy Filippov Date: Fri, 30 Jan 2026 00:48:46 +0300 Subject: [PATCH] Rename http_response_t to http_message_t --- src/client/etcd_state_client.cpp | 6 +++--- src/client/http_client.cpp | 20 ++++++++++---------- src/client/http_client.h | 6 +++--- 3 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/client/etcd_state_client.cpp b/src/client/etcd_state_client.cpp index 1764d01a..dadc6479 100644 --- a/src/client/etcd_state_client.cpp +++ b/src/client/etcd_state_client.cpp @@ -112,7 +112,7 @@ void etcd_state_client_t::etcd_call_oneshot(std::string etcd_address, std::strin "Connection: close\r\n" "\r\n"+req; auto http_cli = http_init(tfd, get_http_ctx()); - auto cb = [http_cli, callback](const http_response_t *response) + auto cb = [http_cli, callback](const http_message_t *response) { std::string err; json11::Json data; @@ -152,7 +152,7 @@ void etcd_state_client_t::etcd_call(std::string api, json11::Json payload, int t "\r\n"+req; retries--; auto cb = [this, api, payload, timeout, retries, interval, callback, - cur_addr = selected_etcd_address](const http_response_t *response) + cur_addr = selected_etcd_address](const http_message_t *response) { std::string err; json11::Json data; @@ -386,7 +386,7 @@ void etcd_state_client_t::start_etcd_watcher() else http_close(etcd_watch_ws); open_websocket(etcd_watch_ws, etcd_address, etcd_api_path+"/watch", { .timeout = etcd_slow_timeout, .ssl = ssl }, - [this, cur_addr = selected_etcd_address](const http_response_t *msg) + [this, cur_addr = selected_etcd_address](const http_message_t *msg) { if (msg->body.length()) { diff --git a/src/client/http_client.cpp b/src/client/http_client.cpp index f9acd994..2f94d449 100644 --- a/src/client/http_client.cpp +++ b/src/client/http_client.cpp @@ -32,7 +32,7 @@ static std::string ws_format_frame(int type, uint64_t size); static bool ws_parse_frame(std::string & buf, uint8_t & type, std::string & res); -static void parse_http_headers(std::string & res, http_response_t *parsed); +static void parse_http_headers(std::string & res, http_message_t *parsed); struct http_context_t { @@ -65,7 +65,7 @@ struct http_co_t #endif timerfd_manager_t *tfd; - std::function response_callback; + std::function response_callback; int request_timeout = 0; bool ssl = false; @@ -87,7 +87,7 @@ struct http_co_t std::vector rbuf; iovec read_iov, send_iov; msghdr read_msg = { 0 }, send_msg = { 0 }; - http_response_t parsed; + http_message_t parsed; uint64_t target_response_size = 0; int onstack = 0; @@ -113,7 +113,7 @@ struct http_co_t #endif void post_message(uint8_t type, const std::string & msg); void send_request(const std::string & host, const std::string & request, - const http_options_t & options, std::function response_callback); + const http_options_t & options, std::function response_callback); }; #define HTTP_CO_CLOSED 0 @@ -172,7 +172,7 @@ http_co_t *http_init(timerfd_manager_t *tfd, http_context_t *ctx) } void open_websocket(http_co_t *handler, const std::string & host, const std::string & path, - const http_options_t & options, std::function response_callback) + const http_options_t & options, std::function response_callback) { if (handler->state == HTTP_CO_KEEPALIVE && (handler->connected_host != host || handler->ssl != options.ssl)) handler->close_connection(); @@ -200,7 +200,7 @@ void open_websocket(http_co_t *handler, const std::string & host, const std::str } void http_request(http_co_t *handler, const std::string & host, const std::string & request, - const http_options_t & options, std::function response_callback) + const http_options_t & options, std::function response_callback) { handler->send_request(host, request, options, response_callback); } @@ -208,7 +208,7 @@ void http_request(http_co_t *handler, const std::string & host, const std::strin void http_co_t::run_cb_and_clear() { parsed.eof = true; - std::function cb; + std::function cb; cb.swap(response_callback); // Call callback after clearing it because otherwise we may hit reenterability problems if (cb != NULL) @@ -217,7 +217,7 @@ void http_co_t::run_cb_and_clear() } void http_co_t::send_request(const std::string & host, const std::string & request, - const http_options_t & options, std::function response_callback) + const http_options_t & options, std::function response_callback) { stackin(); if (state == HTTP_CO_WEBSOCKET) @@ -318,7 +318,7 @@ void http_close(http_co_t *handler) handler->close_connection(); } -void http_response_t::parse_json_response(std::string & error, json11::Json & r) const +void http_message_t::parse_json_response(std::string & error, json11::Json & r) const { if (this->error != "") { @@ -867,7 +867,7 @@ void http_co_t::next_request() } } -static void parse_http_headers(std::string & res, http_response_t *parsed) +static void parse_http_headers(std::string & res, http_message_t *parsed) { int pos = res.find("\r\n"); pos = pos < 0 ? res.length() : pos+2; diff --git a/src/client/http_client.h b/src/client/http_client.h index 02eac974..c36d2c23 100644 --- a/src/client/http_client.h +++ b/src/client/http_client.h @@ -27,7 +27,7 @@ struct http_options_t struct http_context_t; -struct http_response_t +struct http_message_t { std::string error; @@ -48,9 +48,9 @@ http_context_t* http_context_init(const std::string & ssl_cert, const std::strin void http_context_destroy(http_context_t *ctx); http_co_t* http_init(timerfd_manager_t *tfd, http_context_t *ctx = NULL); void open_websocket(http_co_t *handler, const std::string & host, const std::string & path, - const http_options_t & options, std::function on_message); + const http_options_t & options, std::function on_message); void http_request(http_co_t *handler, const std::string & host, const std::string & request, - const http_options_t & options, std::function response_callback); + const http_options_t & options, std::function response_callback); void http_post_message(http_co_t *handler, uint8_t type, const std::string & msg); void http_close(http_co_t *co); void http_destroy(http_co_t *co);