Skip to content
Snippets Groups Projects
Commit b4ccaad6 authored by Sungtae Kim's avatar Sungtae Kim Committed by sungtae kim
Browse files

http.c: Support separated HTTP request

Currently, the Asterisk does not support seperated HTTP request.
This patch make the Asterisk enables to wait lest part of HTTP request.
Also increases acceptable HTTP body length to 40k to support more
larger request.

ASTERISK-28236

Change-Id: I48a401aa64a21c3b37bf3cb4e0486d64b7dd8aa1
parent f0737352
No related branches found
No related tags found
No related merge requests found
...@@ -82,11 +82,18 @@ ...@@ -82,11 +82,18 @@
/*! Maximum application/json or application/x-www-form-urlencoded body content length. */ /*! Maximum application/json or application/x-www-form-urlencoded body content length. */
#if !defined(LOW_MEMORY) #if !defined(LOW_MEMORY)
#define MAX_CONTENT_LENGTH 4096 #define MAX_CONTENT_LENGTH 40960
#else #else
#define MAX_CONTENT_LENGTH 1024 #define MAX_CONTENT_LENGTH 1024
#endif /* !defined(LOW_MEMORY) */ #endif /* !defined(LOW_MEMORY) */
/*! Initial response body length. */
#if !defined(LOW_MEMORY)
#define INITIAL_RESPONSE_BODY_BUFFER 1024
#else
#define INITIAL_RESPONSE_BODY_BUFFER 512
#endif /* !defined(LOW_MEMORY) */
/*! Maximum line length for HTTP requests. */ /*! Maximum line length for HTTP requests. */
#if !defined(LOW_MEMORY) #if !defined(LOW_MEMORY)
#define MAX_HTTP_LINE_LENGTH 4096 #define MAX_HTTP_LINE_LENGTH 4096
...@@ -557,7 +564,7 @@ void ast_http_create_response(struct ast_tcptls_session_instance *ser, int statu ...@@ -557,7 +564,7 @@ void ast_http_create_response(struct ast_tcptls_session_instance *ser, int statu
{ {
char server_name[MAX_SERVER_NAME_LENGTH]; char server_name[MAX_SERVER_NAME_LENGTH];
struct ast_str *server_address = ast_str_create(MAX_SERVER_NAME_LENGTH); struct ast_str *server_address = ast_str_create(MAX_SERVER_NAME_LENGTH);
struct ast_str *out = ast_str_create(MAX_CONTENT_LENGTH); struct ast_str *out = ast_str_create(INITIAL_RESPONSE_BODY_BUFFER);
if (!http_header_data || !server_address || !out) { if (!http_header_data || !server_address || !out) {
ast_free(http_header_data); ast_free(http_header_data);
...@@ -916,14 +923,24 @@ void ast_http_body_read_status(struct ast_tcptls_session_instance *ser, int read ...@@ -916,14 +923,24 @@ void ast_http_body_read_status(struct ast_tcptls_session_instance *ser, int read
static int http_body_read_contents(struct ast_tcptls_session_instance *ser, char *buf, int length, const char *what_getting) static int http_body_read_contents(struct ast_tcptls_session_instance *ser, char *buf, int length, const char *what_getting)
{ {
int res; int res;
int total = 0;
/* Stream is in exclusive mode so we get it all if possible. */ /* Stream is in exclusive mode so we get it all if possible. */
res = ast_iostream_read(ser->stream, buf, length); while (total != length) {
if (res < length) { res = ast_iostream_read(ser->stream, buf + total, length - total);
ast_log(LOG_WARNING, "Short HTTP request %s (Wanted %d)\n", if (res <= 0) {
what_getting, length); break;
}
total += res;
}
if (total != length) {
ast_log(LOG_WARNING, "Wrong HTTP content read. Request %s (Wanted %d, Read %d)\n",
what_getting, length, res);
return -1; return -1;
} }
return 0; return 0;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment