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

Jenkins2 asteriskteam at digium.com
Fri May 4 06:08:43 CDT 2018


Jenkins2 has submitted this change and it was merged. ( https://gerrit.asterisk.org/8912 )

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(-)

Approvals:
  Kevin Harwell: Looks good to me, but someone else must approve
  Richard Mudgett: Looks good to me, but someone else must approve
  Joshua Colp: Looks good to me, approved
  Jenkins2: Approved for Submit



diff --git a/res/res_ari.c b/res/res_ari.c
index 006e25d..75af26b 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -984,9 +984,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;
@@ -1000,7 +1000,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/8912
To unsubscribe, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-MessageType: merged
Gerrit-Change-Id: I4eef036ad54550a4368118cc348765ecac25e0f8
Gerrit-Change-Number: 8912
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Jenkins2
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Kevin Harwell <kharwell at digium.com>
Gerrit-Reviewer: Richard Mudgett <rmudgett at digium.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20180504/e667581d/attachment.html>


More information about the asterisk-code-review mailing list