[asterisk-commits] kharwell: trunk r402795 - in /trunk: ./ res/ari/resource_endpoints.c
SVN commits to the Asterisk project
asterisk-commits at lists.digium.com
Tue Nov 12 17:17:47 CST 2013
Author: kharwell
Date: Tue Nov 12 17:17:45 2013
New Revision: 402795
URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=402795
Log:
ari endpoints: GET /ari/endpoints/{invalid-tech} should return a 404
Was returning a 404 on a valid technology with an empty list of endpoints.
Now checking against the channel tech to make sure the tech itself is valid
and not just an empty list of endpoints.
(issue ASTERISK-22803)
Reported by: David M. Lee
........
Merged revisions 402793 from http://svn.asterisk.org/svn/asterisk/branches/12
Modified:
trunk/ (props changed)
trunk/res/ari/resource_endpoints.c
Propchange: trunk/
------------------------------------------------------------------------------
--- branch-12-merged (original)
+++ branch-12-merged Tue Nov 12 17:17:45 2013
@@ -1,1 +1,1 @@
-/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402738,402755,402757,402767,402769,402787
+/branches/12:1-398558,398560-398577,398579-399305,399307-401390,401392-402738,402755,402757,402767,402769,402787,402793
Modified: trunk/res/ari/resource_endpoints.c
URL: http://svnview.digium.com/svn/asterisk/trunk/res/ari/resource_endpoints.c?view=diff&rev=402795&r1=402794&r2=402795
==============================================================================
--- trunk/res/ari/resource_endpoints.c (original)
+++ trunk/res/ari/resource_endpoints.c Tue Nov 12 17:17:45 2013
@@ -32,6 +32,7 @@
#include "asterisk/astobj2.h"
#include "asterisk/stasis.h"
#include "asterisk/stasis_endpoints.h"
+#include "asterisk/channel.h"
void ast_ari_endpoints_list(struct ast_variable *headers,
struct ast_ari_endpoints_list_args *args,
@@ -89,6 +90,12 @@
struct ao2_iterator i;
void *obj;
+ if (!ast_get_channel_tech(args->tech)) {
+ ast_ari_response_error(response, 404, "Not Found",
+ "No Endpoints found - invalid tech %s", args->tech);
+ return;
+ }
+
cache = ast_endpoint_cache();
if (!cache) {
ast_ari_response_error(
@@ -116,7 +123,7 @@
struct ast_endpoint_snapshot *snapshot = stasis_message_data(msg);
int r;
- if (strcmp(args->tech, snapshot->tech) != 0) {
+ if (strcasecmp(args->tech, snapshot->tech) != 0) {
continue;
}
@@ -128,13 +135,7 @@
}
}
ao2_iterator_destroy(&i);
-
- if (ast_json_array_size(json)) {
- ast_ari_response_ok(response, ast_json_ref(json));
- } else {
- ast_ari_response_error(response, 404, "Not Found",
- "No Endpoints found with tech %s", args->tech);
- }
+ ast_ari_response_ok(response, ast_json_ref(json));
}
void ast_ari_endpoints_get(struct ast_variable *headers,
struct ast_ari_endpoints_get_args *args,
More information about the asterisk-commits
mailing list