[svn-commits] rmudgett: branch rmudgett/http_persistent r417439 - /team/rmudgett/http_persi...

SVN commits to the Digium repositories svn-commits at lists.digium.com
Thu Jun 26 14:25:01 CDT 2014


Author: rmudgett
Date: Thu Jun 26 14:24:58 2014
New Revision: 417439

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=417439
Log:
Don't read the body if the body type isn't what we want to read.

Modified:
    team/rmudgett/http_persistent/main/http.c

Modified: team/rmudgett/http_persistent/main/http.c
URL: http://svnview.digium.com/svn/asterisk/team/rmudgett/http_persistent/main/http.c?view=diff&rev=417439&r1=417438&r2=417439
==============================================================================
--- team/rmudgett/http_persistent/main/http.c (original)
+++ team/rmudgett/http_persistent/main/http.c Thu Jun 26 14:24:58 2014
@@ -834,9 +834,6 @@
 
 #define MAX_CONTENT_LENGTH 1024
 
-	/* Use errno to distinguish errors from no body */
-	errno = 0;
-
 	request = ser->private_data;
 	transfer_encoding = get_transfer_encoding(headers);
 
@@ -1006,15 +1003,19 @@
 	RAII_VAR(char *, buf, NULL, ast_free);
 	RAII_VAR(char *, type, get_content_type(headers), ast_free);
 
+	/* Use errno to distinguish errors from no body */
+	errno = 0;
+
+	if (ast_strlen_zero(type) || strcasecmp(type, "application/json")) {
+		/* Content type is not JSON.  Don't read the body. */
+		return NULL;
+	}
+
 	buf = ast_http_get_contents(&content_length, ser, headers);
-	if (!buf
-		|| !content_length
-		|| ast_strlen_zero(type)
-		|| strcasecmp(type, "application/json")) {
+	if (!buf || !content_length) {
 		/*
 		 * errno already set
 		 * or it is not an error to have zero content
-		 * or content type is not JSON
 		 */
 		return NULL;
 	}
@@ -1042,15 +1043,20 @@
 	RAII_VAR(char *, buf, NULL, ast_free);
 	RAII_VAR(char *, type, get_content_type(headers), ast_free);
 
+	/* Use errno to distinguish errors from no params */
+	errno = 0;
+
+	if (ast_strlen_zero(type) ||
+	    strcasecmp(type, "application/x-www-form-urlencoded")) {
+		/* Content type is not form data.  Don't read the body. */
+		return NULL;
+	}
+
 	buf = ast_http_get_contents(&content_length, ser, headers);
-	if (!buf
-		|| !content_length
-		|| ast_strlen_zero(type)
-		|| strcasecmp(type, "application/x-www-form-urlencoded")) {
+	if (!buf || !content_length) {
 		/*
 		 * errno already set
 		 * or it is not an error to have zero content
-		 * or content type is not form data
 		 */
 		return NULL;
 	}




More information about the svn-commits mailing list