mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #913, APP support complex error.
This commit is contained in:
parent
aebbbadf42
commit
6eae93258a
47 changed files with 1098 additions and 1432 deletions
|
@ -46,15 +46,23 @@ SrsHttpHeartbeat::~SrsHttpHeartbeat()
|
|||
|
||||
void SrsHttpHeartbeat::heartbeat()
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = do_heartbeat();
|
||||
if (err != srs_success) {
|
||||
srs_warn("heartbeat err=%s", srs_error_desc(err).c_str());
|
||||
}
|
||||
srs_freep(err);
|
||||
return;
|
||||
}
|
||||
|
||||
srs_error_t SrsHttpHeartbeat::do_heartbeat()
|
||||
{
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
std::string url = _srs_config->get_heartbeat_url();
|
||||
|
||||
SrsHttpUri uri;
|
||||
if ((ret = uri.initialize(url)) != ERROR_SUCCESS) {
|
||||
srs_error("http uri parse hartbeart url failed. url=%s, ret=%d", url.c_str(), ret);
|
||||
return;
|
||||
if ((err = uri.initialize(url)) != srs_success) {
|
||||
return srs_error_wrap(err, "http uri parse hartbeart url failed. url=%s", url.c_str());
|
||||
}
|
||||
|
||||
std::string ip = "";
|
||||
|
@ -80,30 +88,21 @@ void SrsHttpHeartbeat::heartbeat()
|
|||
|
||||
SrsHttpClient http;
|
||||
if ((err = http.initialize(uri.get_host(), uri.get_port())) != srs_success) {
|
||||
srs_freep(err);
|
||||
return;
|
||||
return srs_error_wrap(err, "init uri=%s", uri.get_url().c_str());
|
||||
}
|
||||
|
||||
std::string req = obj->dumps();
|
||||
ISrsHttpMessage* msg = NULL;
|
||||
if ((err = http.post(uri.get_path(), req, &msg)) != srs_success) {
|
||||
// TODO: FIXME: Use error
|
||||
ret = srs_error_code(err);
|
||||
srs_freep(err);
|
||||
srs_info("http post hartbeart uri failed. url=%s, request=%s, ret=%d",
|
||||
url.c_str(), req.c_str(), ret);
|
||||
return;
|
||||
return srs_error_wrap(err, "http post hartbeart uri failed. url=%s, request=%s", url.c_str(), req.c_str());
|
||||
}
|
||||
SrsAutoFree(ISrsHttpMessage, msg);
|
||||
|
||||
std::string res;
|
||||
if ((ret = msg->body_read_all(res)) != ERROR_SUCCESS) {
|
||||
return;
|
||||
if ((err = msg->body_read_all(res)) != srs_success) {
|
||||
return srs_error_wrap(err, "read body");
|
||||
}
|
||||
|
||||
srs_info("http hook hartbeart success. url=%s, request=%s, response=%s, ret=%d",
|
||||
url.c_str(), req.c_str(), res.c_str(), ret);
|
||||
|
||||
return;
|
||||
return err;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue