From: Stefan Fritsch Date: Sun, 11 Jul 2010 12:07:51 +0000 (+0000) Subject: Improve trace logging of sent response: X-Git-Tag: 2.3.7~95 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0d058b1bfc622ee637669faa957c7df8480223a0;p=apache Improve trace logging of sent response: - log response status - log Date and Server headers git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@963057 13f79535-47bb-0310-9956-ffa450edef68 --- diff --git a/modules/http/http_filters.c b/modules/http/http_filters.c index 0533c803c8..bd8239be8b 100644 --- a/modules/http/http_filters.c +++ b/modules/http/http_filters.c @@ -805,8 +805,6 @@ static apr_status_t send_all_header_fields(header_struct *h, } while (t_elt < t_end); if (APLOGrtrace4(r)) { - ap_log_rerror(APLOG_MARK, APLOG_TRACE4, 0, r, - "Headers sent to client:"); t_elt = (const apr_table_entry_t *)(elts->elts); do { ap_log_rerror(APLOG_MARK, APLOG_TRACE4, 0, r, " %s: %s", @@ -899,7 +897,8 @@ static void basic_http_header(request_rec *r, apr_bucket_brigade *bb, const char *protocol) { char *date; - const char *server; + const char *proxy_date = NULL; + const char *server = NULL; const char *us = ap_get_server_banner(); header_struct h; struct iovec vec[4]; @@ -939,8 +938,6 @@ static void basic_http_header(request_rec *r, apr_bucket_brigade *bb, * generate a new server header / date header */ if (r->proxyreq != PROXYREQ_NONE) { - const char *proxy_date; - proxy_date = apr_table_get(r->headers_out, "Date"); if (!proxy_date) { /* @@ -950,30 +947,42 @@ static void basic_http_header(request_rec *r, apr_bucket_brigade *bb, */ date = apr_palloc(r->pool, APR_RFC822_DATE_LEN); ap_recent_rfc822_date(date, r->request_time); - proxy_date = date; } - form_header_field(&h, "Date", proxy_date); server = apr_table_get(r->headers_out, "Server"); - if (server) { - form_header_field(&h, "Server", server); - } else { - if (*us) { - form_header_field(&h, "Server", ap_get_server_banner()); - } - } } else { date = apr_palloc(r->pool, APR_RFC822_DATE_LEN); ap_recent_rfc822_date(date, r->request_time); - form_header_field(&h, "Date", date); - if (*us) { - form_header_field(&h, "Server", ap_get_server_banner()); - } } + form_header_field(&h, "Date", proxy_date ? proxy_date : date ); + + if (!server && *us) + server = us; + if (server) + form_header_field(&h, "Server", server); + + if (APLOGrtrace3(r)) { + ap_log_rerror(APLOG_MARK, APLOG_TRACE3, 0, r, + "Response sent with status %d%s", + r->status, + APLOGrtrace4(r) ? ", headers:" : ""); + + /* + * Date and Server are less interesting, use TRACE5 for them while + * using TRACE4 for the other headers. + */ + ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r, " %s: %s", "Date", + proxy_date ? proxy_date : date ); + if (server) + ap_log_rerror(APLOG_MARK, APLOG_TRACE5, 0, r, " %s: %s", "Server", + server); + } + + /* unset so we don't send them again */ apr_table_unset(r->headers_out, "Date"); /* Avoid bogosity */ - if (*us) { + if (server) { apr_table_unset(r->headers_out, "Server"); } }