Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

httpClient #3

Open
huangshangbin opened this issue Jun 19, 2019 · 1 comment
Open

httpClient #3

huangshangbin opened this issue Jun 19, 2019 · 1 comment

Comments

@huangshangbin
Copy link

why not have post request

@cherishman2005
Copy link

cherishman2005 commented Dec 15, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants