1
0
Fork 0
mirror of https://github.com/ossrs/srs.git synced 2025-03-09 15:49:59 +00:00

refine http request post. 2.0.132.

This commit is contained in:
winlin 2015-03-06 11:51:20 +08:00
parent 3982ec1d87
commit 964e4be9d4
6 changed files with 88 additions and 259 deletions

View file

@ -35,6 +35,7 @@ using namespace std;
#include <srs_app_json.hpp>
#include <srs_app_http.hpp>
#include <srs_app_utility.hpp>
#include <srs_core_autofree.hpp>
SrsHttpHeartbeat::SrsHttpHeartbeat()
{
@ -73,17 +74,22 @@ void SrsHttpHeartbeat::heartbeat()
srs_api_dump_summaries(ss);
}
ss << __SRS_JOBJECT_END;
std::string data = ss.str();
std::string res;
int status_code;
std::string data = ss.str();
SrsHttpClient http;
if ((ret = http.post(&uri, data, status_code, res)) != ERROR_SUCCESS) {
SrsHttpMessage* msg = NULL;
if ((ret = http.post(&uri, data, &msg)) != ERROR_SUCCESS) {
srs_info("http post hartbeart uri failed. "
"url=%s, request=%s, response=%s, ret=%d",
url.c_str(), data.c_str(), res.c_str(), ret);
return;
}
SrsAutoFree(SrsHttpMessage, msg);
std::string res;
if ((ret = msg->body_read_all(res)) != ERROR_SUCCESS) {
return;
}
srs_info("http hook hartbeart success. "
"url=%s, request=%s, status_code=%d, response=%s, ret=%d",