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/


git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/12@402555 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
David M. Lee
2013-11-08 17:28:40 +00:00
parent 7194a6e59c
commit a274df3a21
3 changed files with 67 additions and 9 deletions

View File

@@ -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);