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 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402795 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
parent
4be01b4598
commit
f6593b4156
1 changed files with 9 additions and 8 deletions
|
@ -32,6 +32,7 @@ ASTERISK_FILE_VERSION(__FILE__, "$Revision$")
|
||||||
#include "asterisk/astobj2.h"
|
#include "asterisk/astobj2.h"
|
||||||
#include "asterisk/stasis.h"
|
#include "asterisk/stasis.h"
|
||||||
#include "asterisk/stasis_endpoints.h"
|
#include "asterisk/stasis_endpoints.h"
|
||||||
|
#include "asterisk/channel.h"
|
||||||
|
|
||||||
void ast_ari_endpoints_list(struct ast_variable *headers,
|
void ast_ari_endpoints_list(struct ast_variable *headers,
|
||||||
struct ast_ari_endpoints_list_args *args,
|
struct ast_ari_endpoints_list_args *args,
|
||||||
|
@ -89,6 +90,12 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
|
||||||
struct ao2_iterator i;
|
struct ao2_iterator i;
|
||||||
void *obj;
|
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();
|
cache = ast_endpoint_cache();
|
||||||
if (!cache) {
|
if (!cache) {
|
||||||
ast_ari_response_error(
|
ast_ari_response_error(
|
||||||
|
@ -116,7 +123,7 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
|
||||||
struct ast_endpoint_snapshot *snapshot = stasis_message_data(msg);
|
struct ast_endpoint_snapshot *snapshot = stasis_message_data(msg);
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
if (strcmp(args->tech, snapshot->tech) != 0) {
|
if (strcasecmp(args->tech, snapshot->tech) != 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -128,13 +135,7 @@ void ast_ari_endpoints_list_by_tech(struct ast_variable *headers,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ao2_iterator_destroy(&i);
|
ao2_iterator_destroy(&i);
|
||||||
|
ast_ari_response_ok(response, ast_json_ref(json));
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
void ast_ari_endpoints_get(struct ast_variable *headers,
|
void ast_ari_endpoints_get(struct ast_variable *headers,
|
||||||
struct ast_ari_endpoints_get_args *args,
|
struct ast_ari_endpoints_get_args *args,
|
||||||
|
|
Loading…
Reference in a new issue