mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #913, use complex error for reload utc time
This commit is contained in:
parent
5c9a12e72a
commit
661eb8b37c
9 changed files with 86 additions and 48 deletions
|
@ -85,6 +85,16 @@ int srs_api_response_jsonp_code(ISrsHttpResponseWriter* w, string callback, int
|
|||
return srs_api_response_jsonp(w, callback, obj->dumps());
|
||||
}
|
||||
|
||||
int srs_api_response_jsonp_code(ISrsHttpResponseWriter* w, string callback, srs_error_t err)
|
||||
{
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("code", SrsJsonAny::integer(srs_error_code(err)));
|
||||
|
||||
return srs_api_response_jsonp(w, callback, obj->dumps());
|
||||
}
|
||||
|
||||
int srs_api_response_json(ISrsHttpResponseWriter* w, string data)
|
||||
{
|
||||
SrsHttpHeader* h = w->header();
|
||||
|
@ -105,6 +115,16 @@ int srs_api_response_json_code(ISrsHttpResponseWriter* w, int code)
|
|||
return srs_api_response_json(w, obj->dumps());
|
||||
}
|
||||
|
||||
int srs_api_response_json_code(ISrsHttpResponseWriter* w, srs_error_t err)
|
||||
{
|
||||
SrsJsonObject* obj = SrsJsonAny::object();
|
||||
SrsAutoFree(SrsJsonObject, obj);
|
||||
|
||||
obj->set("code", SrsJsonAny::integer(srs_error_code(err)));
|
||||
|
||||
return srs_api_response_json(w, obj->dumps());
|
||||
}
|
||||
|
||||
int srs_api_response(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, std::string json)
|
||||
{
|
||||
// no jsonp, directly response.
|
||||
|
@ -129,6 +149,26 @@ int srs_api_response_code(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, int cod
|
|||
return srs_api_response_jsonp_code(w, callback, code);
|
||||
}
|
||||
|
||||
int srs_api_response_code(ISrsHttpResponseWriter* w, ISrsHttpMessage* r, srs_error_t err)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
|
||||
// no jsonp, directly response.
|
||||
if (!r->is_jsonp()) {
|
||||
ret = srs_api_response_json_code(w, err);
|
||||
} else {
|
||||
// jsonp, get function name from query("callback")
|
||||
string callback = r->query_get("callback");
|
||||
ret = srs_api_response_jsonp_code(w, callback, err);
|
||||
}
|
||||
|
||||
if (err != srs_success) {
|
||||
srs_warn("error %s", srs_error_desc(err).c_str());
|
||||
srs_freep(err);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
SrsGoApiRoot::SrsGoApiRoot()
|
||||
{
|
||||
}
|
||||
|
@ -852,6 +892,7 @@ SrsGoApiRaw::~SrsGoApiRaw()
|
|||
int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
||||
{
|
||||
int ret = ERROR_SUCCESS;
|
||||
srs_error_t err = srs_success;
|
||||
|
||||
std::string rpc = r->query_get("rpc");
|
||||
|
||||
|
@ -1126,9 +1167,8 @@ int SrsGoApiRaw::serve_http(ISrsHttpResponseWriter* w, ISrsHttpMessage* r)
|
|||
return srs_api_response_code(w, r, ret);
|
||||
}
|
||||
|
||||
if ((ret = _srs_config->raw_set_utc_time(srs_config_bool2switch(value), applied)) != ERROR_SUCCESS) {
|
||||
srs_error("raw api update utc_time=%s failed. ret=%d", value.c_str(), ret);
|
||||
return srs_api_response_code(w, r, ret);
|
||||
if ((err = _srs_config->raw_set_utc_time(srs_config_bool2switch(value), applied)) != srs_success) {
|
||||
return srs_api_response_code(w, r, srs_error_wrap(err, "raw api update utc_time=%s", value.c_str()));
|
||||
}
|
||||
} else if (scope == "pithy_print_ms") {
|
||||
int ppmv = ::atoi(value.c_str());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue