CppHttpDemo
CppHttpDemo copied to clipboard
httpClient
why not have post request
support post-request, and need to develop by yourself
void HttpClient::SendReq(const std::string &url, const std::string &post_data, ReqCallback req_callback)
{
s_req_callback = req_callback;
mg_mgr mgr;
mg_mgr_init(&mgr, NULL);
auto connection = mg_connect_http(&mgr, OnHttpEvent, url.c_str(), NULL, post_data.c_str());
mg_set_protocol_http_websocket(connection);
printf("Send http request %s\n", url.c_str());
// loop
while (s_exit_flag == 0)
mg_mgr_poll(&mgr, 500);
mg_mgr_free(&mgr);
}
but mg_connect_http() has bug where post-data has '\0', need to modify.