[Asterisk-code-review] Support separated HTTP request (asterisk[master])
sungtae kim
asteriskteam at digium.com
Wed Jan 9 04:33:45 CST 2019
sungtae kim has uploaded this change for review. ( https://gerrit.asterisk.org/10869
Change subject: Support separated HTTP request
......................................................................
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.
Change-Id: I48a401aa64a21c3b37bf3cb4e0486d64b7dd8aa1
---
M main/http.c
1 file changed, 20 insertions(+), 5 deletions(-)
git pull ssh://gerrit.asterisk.org:29418/asterisk refs/changes/69/10869/1
diff --git a/main/http.c b/main/http.c
index dcf90ae..e53bc16 100644
--- a/main/http.c
+++ b/main/http.c
@@ -82,7 +82,7 @@
/*! Maximum application/json or application/x-www-form-urlencoded body content length. */
#if !defined(LOW_MEMORY)
-#define MAX_CONTENT_LENGTH 4096
+#define MAX_CONTENT_LENGTH 40960
#else
#define MAX_CONTENT_LENGTH 1024
#endif /* !defined(LOW_MEMORY) */
@@ -916,14 +916,29 @@
static int http_body_read_contents(struct ast_tcptls_session_instance *ser, char *buf, int length, const char *what_getting)
{
int res;
+ int total;
/* Stream is in exclusive mode so we get it all if possible. */
- res = ast_iostream_read(ser->stream, buf, length);
- if (res < length) {
- ast_log(LOG_WARNING, "Short HTTP request %s (Wanted %d)\n",
- what_getting, length);
+ total = 0;
+ while(1) {
+ res = ast_iostream_read(ser->stream, buf + total, length);
+ if (!res) {
+ break;
+ }
+
+ total += res;
+ if (total >= length) {
+ break;
+ }
+ }
+ ast_log(LOG_DEBUG, "Received message. buf[%s]\n", buf);
+
+ 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 0;
}
--
To view, visit https://gerrit.asterisk.org/10869
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings
Gerrit-Project: asterisk
Gerrit-Branch: master
Gerrit-MessageType: newchange
Gerrit-Change-Id: I48a401aa64a21c3b37bf3cb4e0486d64b7dd8aa1
Gerrit-Change-Number: 10869
Gerrit-PatchSet: 1
Gerrit-Owner: sungtae kim <pchero21 at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190109/c0a6e3be/attachment.html>
More information about the asterisk-code-review
mailing list