[asterisk-commits] mjordan: trunk r411688 - in /trunk: ./ main/http.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Fri Apr 4 10:14:01 CDT 2014


Author: mjordan
Date: Fri Apr  4 10:13:55 2014
New Revision: 411688

URL: http://svnview.digium.com/svn/asterisk?view=rev&rev=411688
Log:
http: Fix spurious ERROR message in responses with no content

When a response has a content length of 0, fwrite would be called to write a
buffer with no data in it. This resulted in the following classic error
message:

  [Apr  3 11:49:17] ERROR[26421] http.c: fwrite() failed: Success

This patch makes it so that we only attempt to write out the content if the
calculated content_length is non-zero.
........

Merged revisions 411687 from http://svn.asterisk.org/svn/asterisk/branches/12

Modified:
    trunk/   (props changed)
    trunk/main/http.c

Propchange: trunk/
------------------------------------------------------------------------------
Binary property 'branch-12-merged' - no diff available.

Modified: trunk/main/http.c
URL: http://svnview.digium.com/svn/asterisk/trunk/main/http.c?view=diff&rev=411688&r1=411687&r2=411688
==============================================================================
--- trunk/main/http.c (original)
+++ trunk/main/http.c Fri Apr  4 10:13:55 2014
@@ -416,7 +416,7 @@
 
 	/* calc content length */
 	if (out) {
-		content_length += strlen(ast_str_buffer(out));
+		content_length += ast_str_strlen(out);
 	}
 
 	if (fd) {
@@ -443,7 +443,7 @@
 
 	/* send content */
 	if (method != AST_HTTP_HEAD || status_code >= 400) {
-		if (out) {
+		if (content_length) {
 			if (fwrite(ast_str_buffer(out), content_length, 1, ser->f) != 1) {
 				ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno));
 			}




More information about the asterisk-commits mailing list