[asterisk-commits] rmudgett: branch 11 r412923 - in /branches/11: ./ main/http.c

SVN commits to the Asterisk project asterisk-commits at lists.digium.com
Wed Apr 23 12:51:23 CDT 2014


Author: rmudgett
Date: Wed Apr 23 12:51:19 2014
New Revision: 412923

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

Backport -r411687 and fix the fix because content_length is the length of
out plus the length of the file controlled by fd.

When a response has an out 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 the content of out if
the out string is non-zero.
........

Merged revisions 412922 from http://svn.asterisk.org/svn/asterisk/branches/1.8

Modified:
    branches/11/   (props changed)
    branches/11/main/http.c

Propchange: branches/11/
------------------------------------------------------------------------------
Binary property 'branch-1.8-merged' - no diff available.

Modified: branches/11/main/http.c
URL: http://svnview.digium.com/svn/asterisk/branches/11/main/http.c?view=diff&rev=412923&r1=412922&r2=412923
==============================================================================
--- branches/11/main/http.c (original)
+++ branches/11/main/http.c Wed Apr 23 12:51:19 2014
@@ -405,7 +405,7 @@
 
 	/* calc content length */
 	if (out) {
-		content_length += strlen(ast_str_buffer(out));
+		content_length += ast_str_strlen(out);
 	}
 
 	if (fd) {
@@ -432,8 +432,8 @@
 
 	/* send content */
 	if (method != AST_HTTP_HEAD || status_code >= 400) {
-		if (out) {
-			if (fwrite(ast_str_buffer(out), content_length, 1, ser->f) != 1) {
+		if (out && ast_str_strlen(out)) {
+			if (fwrite(ast_str_buffer(out), ast_str_strlen(out), 1, ser->f) != 1) {
 				ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno));
 			}
 		}




More information about the asterisk-commits mailing list