You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cvs@httpd.apache.org by el...@apache.org on 2016/07/03 09:48:07 UTC

svn commit: r1751138 - /httpd/httpd/trunk/server/util_script.c

Author: elukey
Date: Sun Jul  3 09:48:06 2016
New Revision: 1751138

URL: http://svn.apache.org/viewvc?rev=1751138&view=rev
Log:
Improve the FCGI/CGI Last-Modified header value handling.

Patch from Yann after a discussion on the dev@ mailing list. 
ap_scan_script_header_err_core_ex is now using apr_date_parse_rfc 
in order to recognize non-GMT datestr following RFC822/1123
and transforming them to GMT rather than replacing the value
with GMT now (that could add httpd's processing time to the
original value). Logging has also been improved from my initial
solution.
 

Modified:
    httpd/httpd/trunk/server/util_script.c

Modified: httpd/httpd/trunk/server/util_script.c
URL: http://svn.apache.org/viewvc/httpd/httpd/trunk/server/util_script.c?rev=1751138&r1=1751137&r2=1751138&view=diff
==============================================================================
--- httpd/httpd/trunk/server/util_script.c (original)
+++ httpd/httpd/trunk/server/util_script.c Sun Jul  3 09:48:06 2016
@@ -665,28 +665,25 @@ AP_DECLARE(int) ap_scan_script_header_er
          * pass it on blindly because of restrictions on future or invalid values.
          */
         else if (!ap_cstr_casecmp(w, "Last-Modified")) {
-            apr_time_t last_modified_date = apr_date_parse_http(l);
-            if (last_modified_date != APR_DATE_BAD) {
+            apr_time_t parsed_date = apr_date_parse_rfc(l);
+            if (parsed_date != APR_DATE_BAD) {
+                apr_time_t last_modified_date = parsed_date;
+                apr_time_t now = apr_time_now();
+                if (parsed_date > now) {
+                    last_modified_date = now;
+                }
                 ap_update_mtime(r, last_modified_date);
                 ap_set_last_modified(r);
-                if (APLOGrtrace1(r)) {
-                    const char* datestr = apr_table_get(r->headers_out,
-                                                        "Last-Modified");
-                    apr_time_t timestamp = apr_date_parse_http(datestr);
-                    if (timestamp < last_modified_date) {
-                        char *last_modified_datestr = apr_palloc(r->pool,
-                                                                 APR_RFC822_DATE_LEN);
-                        apr_rfc822_date(last_modified_datestr, last_modified_date);
-                        ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE1, 0, r,
-                                      "The Last-Modified header value '%s' "
-                                      "(parsed as RFC822/RFC1123 datetime, "
-                                      "that assumes the GMT timezone) "
-                                      "has been replaced with: '%s'. "
-                                      "An origin server with a clock must not send "
-                                      "a Last-Modified date that is later than the "
-                                      "server's time of message origination.",
-                                      last_modified_datestr, datestr);
-                    }
+                if (APLOGrtrace1(r) &&
+                        (parsed_date > now ||
+                         parsed_date != apr_date_parse_http(l))) {
+                    ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE1, 0, r,
+                                  "The Last-Modified header value '%s' (%s) "
+                                  "has been replaced with '%s'", l,
+                                  parsed_date > now ? "in the future"
+                                                    : "non GMT",
+                                  apr_table_get(r->headers_out,
+                                                "Last-Modified"));
                 }
             }
             else {