[Asterisk-code-review] res ari: Remove requirement that body exists when debug is on. (asterisk[15])

Joshua Colp asteriskteam at digium.com
Thu May 3 06:36:52 CDT 2018


Joshua Colp has uploaded this change for review. ( https://gerrit.asterisk.org/8913


Change subject: res_ari: Remove requirement that body exists when debug is on.
......................................................................

res_ari: Remove requirement that body exists when debug is on.

The "ari set debug" code for incoming requests incorrectly assumed
that all requests would contain a body. If one did not exist the
request would be incorrectly rejected. The response that was sent
was also incomplete as an incorrect function was used to construct
the response.

The code has now been changed to no longer require a request to have
a body and the response updated to use the correct function.

ASTERISK-27801

Change-Id: I4eef036ad54550a4368118cc348765ecac25e0f8
---
M res/res_ari.c
1 file changed, 3 insertions(+), 3 deletions(-)



  git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/13/8913/1

diff --git a/res/res_ari.c b/res/res_ari.c
index 9104ede..8a01809 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -985,9 +985,9 @@
 		struct ast_str *buf = ast_str_create(512);
 		char *str = ast_json_dump_string_format(body, ast_ari_json_format());
 
-		if (!buf || !str) {
+		if (!buf || (body && !str)) {
 			ast_http_request_close_on_completion(ser);
-			ast_http_error(ser, 500, "Server Error", "Out of memory");
+			ast_ari_response_error(&response, 500, "Server Error", "Out of memory");
 			ast_json_free(str);
 			ast_free(buf);
 			goto request_failed;
@@ -1001,7 +1001,7 @@
 		for (var = get_params; var; var = var->next) {
 			ast_str_append(&buf, 0, "%s: %s\n", var->name, var->value);
 		}
-		ast_verbose("%sbody:\n%s\n\n", ast_str_buffer(buf), str);
+		ast_verbose("%sbody:\n%s\n\n", ast_str_buffer(buf), S_OR(str, ""));
 		ast_json_free(str);
 		ast_free(buf);
 	}

-- 
To view, visit https://gerrit.asterisk.org/8913
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 15
Gerrit-MessageType: newchange
Gerrit-Change-Id: I4eef036ad54550a4368118cc348765ecac25e0f8
Gerrit-Change-Number: 8913
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180503/8f6c2aa4/attachment.html>


More information about the asterisk-code-review mailing list