Author: file
Date: Sat Feb 21 14:48:17 2015
New Revision: 432155

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=432155
Log:
res_ari_channels: Return a 404 response when a requested channel variable does 
not exist.

This change makes it so that if a channel variable is requested and it does not 
exist
a 404 response will be returned instead of an allocation failed response. This 
makes
it easier to debug and figure out what is going on for a user.

ASTERISK-24677 #close
Reported by: Joshua Colp
........

Merged revisions 432154 from http://svn.asterisk.org/svn/asterisk/branches/13

Modified:
    trunk/   (props changed)
    trunk/res/ari/resource_channels.c
    trunk/res/res_ari_channels.c
    trunk/rest-api/api-docs/channels.json

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-13-merged' - no diff available.

Modified: trunk/res/ari/resource_channels.c
URL: 
http://svnview.digium.com/svn/asterisk/trunk/res/ari/resource_channels.c?view=diff&rev=432155&r1=432154&r2=432155
==============================================================================
--- trunk/res/ari/resource_channels.c (original)
+++ trunk/res/ari/resource_channels.c Sat Feb 21 14:48:17 2015
@@ -1242,6 +1242,11 @@
 
        ast_assert(response != NULL);
 
+       if (!value) {
+               ast_ari_response_alloc_failed(response);
+               return;
+       }
+
        if (ast_strlen_zero(args->variable)) {
                ast_ari_response_error(
                        response, 400, "Bad Request",
@@ -1280,7 +1285,9 @@
                }
        } else {
                if (!ast_str_retrieve_variable(&value, 0, channel, NULL, 
args->variable)) {
-                       ast_ari_response_alloc_failed(response);
+                       ast_ari_response_error(
+                               response, 404, "Variable Not Found",
+                               "Provided variable was not found");
                        return;
                }
        }

Modified: trunk/res/res_ari_channels.c
URL: 
http://svnview.digium.com/svn/asterisk/trunk/res/res_ari_channels.c?view=diff&rev=432155&r1=432154&r2=432155
==============================================================================
--- trunk/res/res_ari_channels.c (original)
+++ trunk/res/res_ari_channels.c Sat Feb 21 14:48:17 2015
@@ -2173,7 +2173,7 @@
        case 500: /* Internal Server Error */
        case 501: /* Not Implemented */
        case 400: /* Missing variable parameter. */
-       case 404: /* Channel not found */
+       case 404: /* Channel or variable not found */
        case 409: /* Channel not in a Stasis application */
                is_valid = 1;
                break;

Modified: trunk/rest-api/api-docs/channels.json
URL: 
http://svnview.digium.com/svn/asterisk/trunk/rest-api/api-docs/channels.json?view=diff&rev=432155&r1=432154&r2=432155
==============================================================================
--- trunk/rest-api/api-docs/channels.json (original)
+++ trunk/rest-api/api-docs/channels.json Sat Feb 21 14:48:17 2015
@@ -1199,7 +1199,7 @@
                                                },
                                                {
                                                        "code": 404,
-                                                       "reason": "Channel not 
found"
+                                                       "reason": "Channel or 
variable not found"
                                                },
                                                {
                                                        "code": 409,


-- 
_____________________________________________________________________
-- Bandwidth and Colocation Provided by http://www.api-digital.com --

svn-commits mailing list
To UNSUBSCRIBE or update options visit:
   http://lists.digium.com/mailman/listinfo/svn-commits

Reply via email to