mirror of
https://github.com/asterisk/asterisk.git
synced 2025-09-05 12:16:00 +00:00
http.c: Reduce log spam
Messages like "fwrite() failed: Connection reset by peer" are no help whatsoever, especially since they can be caused simply by a client disconnecting. * Make those WARNINGs DEBUGs. * Check the return of the headers fprintf. Change-Id: I17bd5f3621514152a7b2b263c801324c5e96568b
This commit is contained in:
13
main/http.c
13
main/http.c
@@ -505,7 +505,7 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* send http header */
|
/* send http header */
|
||||||
fprintf(ser->f,
|
if (fprintf(ser->f,
|
||||||
"HTTP/1.1 %d %s\r\n"
|
"HTTP/1.1 %d %s\r\n"
|
||||||
"%s"
|
"%s"
|
||||||
"Date: %s\r\n"
|
"Date: %s\r\n"
|
||||||
@@ -521,17 +521,20 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
|
|||||||
static_content ? "" : "Cache-Control: no-cache, no-store\r\n",
|
static_content ? "" : "Cache-Control: no-cache, no-store\r\n",
|
||||||
http_header ? ast_str_buffer(http_header) : "",
|
http_header ? ast_str_buffer(http_header) : "",
|
||||||
content_length
|
content_length
|
||||||
);
|
) <= 0) {
|
||||||
|
ast_debug(1, "fprintf() failed: %s\n", strerror(errno));
|
||||||
|
close_connection = 1;
|
||||||
|
}
|
||||||
|
|
||||||
/* send content */
|
/* send content */
|
||||||
if (method != AST_HTTP_HEAD || status_code >= 400) {
|
if (!close_connection && (method != AST_HTTP_HEAD || status_code >= 400)) {
|
||||||
if (out && ast_str_strlen(out)) {
|
if (out && ast_str_strlen(out)) {
|
||||||
/*
|
/*
|
||||||
* NOTE: Because ser->f is a non-standard FILE *, fwrite() will probably not
|
* NOTE: Because ser->f is a non-standard FILE *, fwrite() will probably not
|
||||||
* behave exactly as documented.
|
* behave exactly as documented.
|
||||||
*/
|
*/
|
||||||
if (fwrite(ast_str_buffer(out), ast_str_strlen(out), 1, ser->f) != 1) {
|
if (fwrite(ast_str_buffer(out), ast_str_strlen(out), 1, ser->f) != 1) {
|
||||||
ast_log(LOG_ERROR, "fwrite() failed: %s\n", strerror(errno));
|
ast_debug(1, "fwrite() failed: %s\n", strerror(errno));
|
||||||
close_connection = 1;
|
close_connection = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,7 +549,7 @@ void ast_http_send(struct ast_tcptls_session_instance *ser,
|
|||||||
* behave exactly as documented.
|
* behave exactly as documented.
|
||||||
*/
|
*/
|
||||||
if (fwrite(buf, len, 1, ser->f) != 1) {
|
if (fwrite(buf, len, 1, ser->f) != 1) {
|
||||||
ast_log(LOG_WARNING, "fwrite() failed: %s\n", strerror(errno));
|
ast_debug(1, "fwrite() failed: %s\n", strerror(errno));
|
||||||
close_connection = 1;
|
close_connection = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user