[Asterisk-code-review] Revert "http.c: Support separated HTTP request" (...asterisk[13])

Friendly Automation asteriskteam at digium.com
Thu Feb 28 08:37:05 CST 2019


Friendly Automation has submitted this change and it was merged. ( https://gerrit.asterisk.org/c/asterisk/+/11063 )

Change subject: Revert "http.c: Support separated HTTP request"
......................................................................

Revert "http.c: Support separated HTTP request"

This reverts commit 148ddfba9afc83b102fadabecf67d48a65e30e4a.

Reason for revert: Under 13 this change appears to break HTTP
body processing, causing test failures and problems.

Change-Id: Ica47ca2cac1b21c6ef907c1ffbfaf2cebdea8e80
---
M main/http.c
1 file changed, 11 insertions(+), 29 deletions(-)

Approvals:
  Sean Bright: Looks good to me, but someone else must approve
  George Joseph: Looks good to me, approved
  Friendly Automation: Approved for Submit



diff --git a/main/http.c b/main/http.c
index cf2ff5e..136c916 100644
--- a/main/http.c
+++ b/main/http.c
@@ -84,18 +84,11 @@
 
 /*! Maximum application/json or application/x-www-form-urlencoded body content length. */
 #if !defined(LOW_MEMORY)
-#define MAX_CONTENT_LENGTH 40960
+#define MAX_CONTENT_LENGTH 4096
 #else
 #define MAX_CONTENT_LENGTH 1024
 #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. */
 #if !defined(LOW_MEMORY)
 #define MAX_HTTP_LINE_LENGTH 4096
@@ -570,7 +563,7 @@
 {
 	char server_name[MAX_SERVER_NAME_LENGTH];
 	struct ast_str *server_address = ast_str_create(MAX_SERVER_NAME_LENGTH);
-	struct ast_str *out = ast_str_create(INITIAL_RESPONSE_BODY_BUFFER);
+	struct ast_str *out = ast_str_create(MAX_CONTENT_LENGTH);
 
 	if (!http_header_data || !server_address || !out) {
 		ast_free(http_header_data);
@@ -929,30 +922,19 @@
 static int http_body_read_contents(struct ast_tcptls_session_instance *ser, char *buf, int length, const char *what_getting)
 {
 	int res;
-	int total = 0;
 
-	/* Stream is in exclusive mode so we get it all if possible. */
-	while (total != length) {
-		/*
-		 * NOTE: Because ser->f is a non-standard FILE *, fread() does not behave as
-		 * documented.
-		 */
+	/*
+	 * NOTE: Because ser->f is a non-standard FILE *, fread() does not behave as
+	 * documented.
+	 */
 
-		/* Stay in fread until get all the expected data or timeout. */
-		res = fread(buf + total, length - total, 1, ser->f);
-		if (res <= 0) {
-			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);
+	/* Stay in fread until get all the expected data or timeout. */
+	res = fread(buf, length, 1, ser->f);
+	if (res < 1) {
+		ast_log(LOG_WARNING, "Short HTTP request %s (Wanted %d)\n",
+			what_getting, length);
 		return -1;
 	}
-
 	return 0;
 }
 

-- 
To view, visit https://gerrit.asterisk.org/c/asterisk/+/11063
To unsubscribe, or for help writing mail filters, visit https://gerrit.asterisk.org/settings

Gerrit-Project: asterisk
Gerrit-Branch: 13
Gerrit-Change-Id: Ica47ca2cac1b21c6ef907c1ffbfaf2cebdea8e80
Gerrit-Change-Number: 11063
Gerrit-PatchSet: 1
Gerrit-Owner: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Friendly Automation
Gerrit-Reviewer: George Joseph <gjoseph at digium.com>
Gerrit-Reviewer: Joshua Colp <jcolp at digium.com>
Gerrit-Reviewer: Matthew Fredrickson <creslin at digium.com>
Gerrit-Reviewer: Sean Bright <sean.bright at gmail.com>
Gerrit-Reviewer: sungtae kim <pchero21 at gmail.com>
Gerrit-MessageType: merged
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-code-review/attachments/20190228/f450f763/attachment-0001.html>


More information about the asterisk-code-review mailing list