diff options
author | Matthew Jordan <mjordan@digium.com> | 2014-04-04 15:13:55 +0000 |
---|---|---|
committer | Matthew Jordan <mjordan@digium.com> | 2014-04-04 15:13:55 +0000 |
commit | 73f337d97be6600f283a6149a7dfd107fb3a66e3 (patch) | |
tree | 414b8aa9b150e1cd70ba5625163496f9eba7a05d /main/http.c | |
parent | 045285f8e35b391d03abe897b0a581be0248d1ee (diff) |
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
git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411688 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/http.c')
-rw-r--r-- | main/http.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/main/http.c b/main/http.c index 1009afcc2..d6bc006f3 100644 --- a/main/http.c +++ b/main/http.c @@ -416,7 +416,7 @@ void ast_http_send(struct ast_tcptls_session_instance *ser, /* calc content length */ if (out) { - content_length += strlen(ast_str_buffer(out)); + content_length += ast_str_strlen(out); } if (fd) { @@ -443,7 +443,7 @@ void ast_http_send(struct ast_tcptls_session_instance *ser, /* 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)); } |