Rename http_response_t to http_message_t
This commit is contained in:
@@ -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;
|
||||
@@ -378,7 +378,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())
|
||||
{
|
||||
|
||||
+10
-10
@@ -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<void(const http_response_t*)> response_callback;
|
||||
std::function<void(const http_message_t*)> response_callback;
|
||||
|
||||
int request_timeout = 0;
|
||||
bool ssl = false;
|
||||
@@ -87,7 +87,7 @@ struct http_co_t
|
||||
std::vector<uint8_t> 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<void(const http_response_t *response)> response_callback);
|
||||
const http_options_t & options, std::function<void(const http_message_t *response)> 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<void(const http_response_t *msg)> response_callback)
|
||||
const http_options_t & options, std::function<void(const http_message_t *msg)> 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<void(const http_response_t *response)> response_callback)
|
||||
const http_options_t & options, std::function<void(const http_message_t *response)> 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<void(const http_response_t*)> cb;
|
||||
std::function<void(const http_message_t*)> 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<void(const http_response_t *response)> response_callback)
|
||||
const http_options_t & options, std::function<void(const http_message_t *response)> 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;
|
||||
|
||||
@@ -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<void(const http_response_t *msg)> on_message);
|
||||
const http_options_t & options, std::function<void(const http_message_t *msg)> on_message);
|
||||
void http_request(http_co_t *handler, const std::string & host, const std::string & request,
|
||||
const http_options_t & options, std::function<void(const http_response_t *response)> response_callback);
|
||||
const http_options_t & options, std::function<void(const http_message_t *response)> 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);
|
||||
|
||||
Reference in New Issue
Block a user