summaryrefslogtreecommitdiff
path: root/res/res_ari.c
diff options
context:
space:
mode:
authorRichard Mudgett <rmudgett@digium.com>2014-07-03 17:16:55 +0000
committerRichard Mudgett <rmudgett@digium.com>2014-07-03 17:16:55 +0000
commitdbec5e0d8d2d8c51e14f912354d12e1f713b6077 (patch)
tree0d4c189e72b3e0a3a4194efcb62b5779597245d6 /res/res_ari.c
parent758b13858b79256104c0f81a9adf1924df7d2da9 (diff)
HTTP: Add persistent connection support.
Persistent HTTP connection support is needed due to the increased usage of the Asterisk core HTTP transport and the frequency at which REST API calls are going to be issued. * Add http.conf session_keep_alive option to enable persistent connections. * Parse and discard optional chunked body extension information and trailing request headers. * Increased the maximum application/json and application/x-www-form-urlencoded body size allowed to 4k. The previous 1k was kind of small. * Removed a couple inlined versions of ast_http_manid_from_vars() by calling the function. manager.c:generic_http_callback() and res_http_post.c:http_post_callback() * Add missing va_end() in ast_ari_response_error(). * Eliminated unnecessary RAII_VAR() use in http.c:auth_create(). ASTERISK-23552 #close Reported by: Scott Griepentrog Review: https://reviewboard.asterisk.org/r/3691/ ........ Merged revisions 417880 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@417901 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'res/res_ari.c')
-rw-r--r--res/res_ari.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/res/res_ari.c b/res/res_ari.c
index acdbbfe9a..0d80babbb 100644
--- a/res/res_ari.c
+++ b/res/res_ari.c
@@ -262,6 +262,7 @@ void ast_ari_response_error(struct ast_ari_response *response,
va_start(ap, message_fmt);
message = ast_json_vstringf(message_fmt, ap);
+ va_end(ap);
response->message = ast_json_pack("{s: o}",
"message", ast_json_ref(message));
response->response_code = response_code;
@@ -884,23 +885,25 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
* with us.
*/
post_vars = ast_http_get_post_vars(ser, headers);
- if (get_params == NULL) {
+ if (!post_vars) {
switch (errno) {
case EFBIG:
ast_ari_response_error(&response, 413,
"Request Entity Too Large",
"Request body too large");
- break;
+ goto request_failed;
case ENOMEM:
ast_ari_response_error(&response, 500,
"Internal Server Error",
"Error processing request");
- break;
+ goto request_failed;
case EIO:
ast_ari_response_error(&response, 400,
"Bad Request", "Error parsing request body");
- break;
+ goto request_failed;
}
+ }
+ if (get_params == NULL) {
get_params = post_vars;
} else if (get_params && post_vars) {
/* Has both post_vars and get_params */
@@ -963,6 +966,7 @@ static int ast_ari_callback(struct ast_tcptls_session_instance *ser,
return 0;
}
+request_failed:
/* If you explicitly want to have no content, set message to
* ast_json_null().
*/