From 97a8debd90e4d31f15803dc26e8884bf34d7650e Mon Sep 17 00:00:00 2001 From: "David M. Lee" Date: Fri, 8 Nov 2013 17:29:53 +0000 Subject: ari: Add application/x-www-form-urlencoded parameter support ARI POST calls only accept parameters via the URL's query string. While this works, it's atypical for HTTP API's in general, and specifically frowned upon with RESTful API's. This patch adds parsing for application/x-www-form-urlencoded request bodies if they are sent in with the request. Any variables parsed this way are prepended to the variable list supplied by the query string. (closes issue ASTERISK-22743) Review: https://reviewboard.asterisk.org/r/2986/ ........ Merged revisions 402555 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@402557 65c4cc65-6c06-0410-ace0-fbb531ad65f3 --- main/manager.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'main/manager.c') diff --git a/main/manager.c b/main/manager.c index a531feb80..01cc75474 100644 --- a/main/manager.c +++ b/main/manager.c @@ -6723,6 +6723,20 @@ static int generic_http_callback(struct ast_tcptls_session_instance *ser, params = ast_http_get_post_vars(ser, headers); } + if (!params) { + switch (errno) { + case EFBIG: + ast_http_send(ser, AST_HTTP_POST, 413, "Request Entity Too Large", NULL, NULL, 0, 0); + break; + case ENOMEM: + ast_http_send(ser, AST_HTTP_POST, 500, "Internal Server Error", NULL, NULL, 0, 0); + break; + case EIO: + ast_http_send(ser, AST_HTTP_POST, 400, "Bad Request", NULL, NULL, 0, 0); + break; + } + } + for (v = params; v && m.hdrcount < ARRAY_LEN(m.headers); v = v->next) { hdrlen = strlen(v->name) + strlen(v->value) + 3; m.headers[m.hdrcount] = ast_malloc(hdrlen); -- cgit v1.2.3