summaryrefslogtreecommitdiff
path: root/main/http.c
diff options
context:
space:
mode:
authorScott Griepentrog <sgriepentrog@digium.com>2014-03-28 16:18:56 +0000
committerScott Griepentrog <sgriepentrog@digium.com>2014-03-28 16:18:56 +0000
commit0d057e67915d8d4f1b535d54bbcf5fb20a3e657f (patch)
tree697660b264a1c3bc360906ebf7ac1907410734db /main/http.c
parent2cfa9b4b772dbde48f8c0f7357341e9eea39311b (diff)
http: response body often missing after specific request
This patch works around a problem with the HTTP body being dropped from the response to a specific client and under specific circumstances: a) Client request comes from node.js user agent "Shred" via use of swagger-client library. b) Asterisk and Client are *not* on the same host or TCP/IP stack In testing this problem, it has been determined that the write of the HTTP body is lost, even if the data is written using low level write function. The only solution found is to instruct the TCP stack with the shutdown function to flush the last write and finish the transmission. See review for more details. ASTERISK-23548 #close (closes issue ASTERISK-23548) Reported by: Sam Galarneau Review: https://reviewboard.asterisk.org/r/3402/ ........ Merged revisions 411462 from http://svn.asterisk.org/svn/asterisk/branches/1.8 ........ Merged revisions 411463 from http://svn.asterisk.org/svn/asterisk/branches/11 ........ Merged revisions 411465 from http://svn.asterisk.org/svn/asterisk/branches/12 git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@411469 65c4cc65-6c06-0410-ace0-fbb531ad65f3
Diffstat (limited to 'main/http.c')
-rw-r--r--main/http.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/main/http.c b/main/http.c
index e2982a73b..1009afcc2 100644
--- a/main/http.c
+++ b/main/http.c
@@ -444,7 +444,9 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
/* send content */
if (method != AST_HTTP_HEAD || status_code >= 400) {
if (out) {
- fprintf(ser->f, "%s", ast_str_buffer(out));
+ if (fwrite(ast_str_buffer(out), content_length, 1, ser->f) != 1) {
+ ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno));
+ }
}
if (fd) {
@@ -466,8 +468,7 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
ast_free(out);
}
- fclose(ser->f);
- ser->f = 0;
+ ast_tcptls_close_session_file(ser);
return;
}