diff options
author | Richard Mudgett <rmudgett@digium.com> | 2014-07-03 19:06:12 +0000 |
---|---|---|
committer | Richard Mudgett <rmudgett@digium.com> | 2014-07-03 19:06:12 +0000 |
commit | 9b10813a2b2aa0edc5005aa9dc61c303a9ec6766 (patch) | |
tree | b735ea18efa5a9d8a7521c7d257b8bfc6e2552ab /res | |
parent | bc4b236d71f1f44e3bf071d99ec13122f449ad6c (diff) |
res_ari: Fix some off-nominal paths just dropping the HTTP connection.
* Removed some incorrect newlines on ast_http_error() messages in
manager.c.
* Removed an incorrect newline in res_ari_channels.c.
Addendum to ASTERISK-23552
........
Merged revisions 417932 from http://svn.asterisk.org/svn/asterisk/branches/12
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417933 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res')
-rw-r--r-- | res/ari/resource_channels.c | 2 | ||||
-rw-r--r-- | res/res_ari.c | 20 |
2 files changed, 14 insertions, 8 deletions
diff --git a/res/ari/resource_channels.c b/res/ari/resource_channels.c index 647344303..6cc00ce41 100644 --- a/res/ari/resource_channels.c +++ b/res/ari/resource_channels.c @@ -790,7 +790,7 @@ static void ari_channels_handle_originate_with_id(const char *args_endpoint, if ((assignedids.uniqueid && AST_MAX_PUBLIC_UNIQUEID < strlen(assignedids.uniqueid)) || (assignedids.uniqueid2 && AST_MAX_PUBLIC_UNIQUEID < strlen(assignedids.uniqueid2))) { ast_ari_response_error(response, 400, "Bad Request", - "Uniqueid length exceeds maximum of %d\n", AST_MAX_PUBLIC_UNIQUEID); + "Uniqueid length exceeds maximum of %d", AST_MAX_PUBLIC_UNIQUEID); return; } diff --git a/res/res_ari.c b/res/res_ari.c index 0d80babbb..2b6cb231b 100644 --- a/res/res_ari.c +++ b/res/res_ari.c @@ -860,22 +860,27 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser, RAII_VAR(struct ast_str *, response_body, ast_str_create(256), ast_free); RAII_VAR(struct ast_ari_conf_user *, user, NULL, ao2_cleanup); struct ast_ari_response response = {}; - int ret = 0; RAII_VAR(struct ast_variable *, post_vars, NULL, ast_variables_destroy); if (!response_body) { - return -1; + ast_http_request_close_on_completion(ser); + ast_http_error(ser, 500, "Server Error", "Out of memory"); + return 0; } response.headers = ast_str_create(40); if (!response.headers) { - return -1; + ast_http_request_close_on_completion(ser); + ast_http_error(ser, 500, "Server Error", "Out of memory"); + return 0; } conf = ast_ari_config_get(); if (!conf || !conf->general) { ast_free(response.headers); - return -1; + ast_http_request_close_on_completion(ser); + ast_http_error(ser, 500, "Server Error", "URI handler config missing"); + return 0; } process_cors_request(headers, &response); @@ -893,9 +898,10 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser, "Request body too large"); goto request_failed; case ENOMEM: + ast_http_request_close_on_completion(ser); ast_ari_response_error(&response, 500, "Internal Server Error", - "Error processing request"); + "Out of memory"); goto request_failed; case EIO: ast_ari_response_error(&response, 400, @@ -940,6 +946,7 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser, "WWW-Authenticate: Basic realm=\"%s\"\r\n", conf->general->auth_realm); } else if (!ast_fully_booted) { + ast_http_request_close_on_completion(ser); ast_ari_response_error(&response, 503, "Service Unavailable", "Asterisk not booted"); } else if (user->read_only && method != AST_HTTP_GET && method != AST_HTTP_OPTIONS) { ast_ari_response_error(&response, 403, "Forbidden", "Write access denied"); @@ -986,7 +993,6 @@ request_failed: response.response_text = "Internal Server Error"; ast_str_set(&response_body, 0, "%s", ""); ast_str_set(&response.headers, 0, "%s", ""); - ret = -1; } } @@ -999,7 +1005,7 @@ request_failed: response_body = NULL; ast_json_unref(response.message); - return ret; + return 0; } static struct ast_http_uri http_uri = { |