]> granicus.if.org Git - apache/commitdiff
This evil little change modifies the interface to ap_parseHTTPdate()
authorRoy T. Fielding <fielding@apache.org>
Thu, 26 Aug 1999 14:53:24 +0000 (14:53 +0000)
committerRoy T. Fielding <fielding@apache.org>
Thu, 26 Aug 1999 14:53:24 +0000 (14:53 +0000)
for no good reason.  It'll be backed out real soon.

Submitted by: pthreads leftovers

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@83772 13f79535-47bb-0310-9956-ffa450edef68

include/util_date.h
modules/http/http_protocol.c
server/util_date.c
server/util_script.c

index 8e2051024e649f5a506c90d41babf511851fb64f..beb68e9534d61109b6737dca88489df37a1f63af 100644 (file)
@@ -76,7 +76,7 @@ extern "C" {
 
 API_EXPORT(int) ap_checkmask(const char *data, const char *mask);
 API_EXPORT(time_t) ap_tm2sec(const struct tm *t);
-API_EXPORT(time_t) ap_parseHTTPdate(const char *date);
+API_EXPORT(time_t) ap_parseHTTPdate(const char *date, time_t * retval);
 
 #ifdef __cplusplus
 }
index 8617a664672b1e3e300bd04b9cd813425a013f82..531047f06c82afa7f27e683d94cd25fe99bc42d5 100644 (file)
@@ -425,10 +425,12 @@ API_EXPORT(int) ap_meets_conditions(request_rec *r)
          */
         if_unmodified = ap_table_get(r->headers_in, "If-Unmodified-Since");
         if (if_unmodified != NULL) {
-            time_t ius = ap_parseHTTPdate(if_unmodified);
-
-            if ((ius != BAD_DATE) && (mtime > ius)) {
-                return HTTP_PRECONDITION_FAILED;
+           /* ZZZ we are changing time funcs to AP time thread funcs.
+              and we need to check return values of ap_parseHTTPdate. */
+            time_t ius ;
+           if (ap_parseHTTPdate(if_unmodified, &ius) == 1
+               && (mtime > ius)) {
+               return HTTP_PRECONDITION_FAILED;
             }
         }
     }
@@ -478,9 +480,12 @@ API_EXPORT(int) ap_meets_conditions(request_rec *r)
     else if ((r->method_number == M_GET)
              && ((if_modified_since =
                   ap_table_get(r->headers_in, "If-Modified-Since")) != NULL)) {
-        time_t ims = ap_parseHTTPdate(if_modified_since);
-
-        if ((ims >= mtime) && (ims <= r->request_time)) {
+        time_t ims;
+       if (ap_parseHTTPdate(if_modified_since, &ims) != 1) {
+           ap_log_error(APLOG_MARK, APLOG_NOERRNO|APLOG_WARNING,
+                        r->server, "bogus if-modified-since-header");
+       }
+        else if ((ims >= mtime) && (ims <= r->request_time)) {
             return HTTP_NOT_MODIFIED;
         }
     }
index 5111a600f0d5507a1d402c80f1ec8c1e98132eb1..43d322eea0256c4d3672b80218764115be522ed2 100644 (file)
@@ -214,7 +214,7 @@ API_EXPORT(time_t) ap_tm2sec(const struct tm * t)
  * but many changes since then.
  *
  */
-API_EXPORT(time_t) ap_parseHTTPdate(const char *date)
+API_EXPORT(time_t) ap_parseHTTPdate(const char *date, time_t * retval)
 {
     struct tm ds;
     int mint, mon;
@@ -228,7 +228,7 @@ API_EXPORT(time_t) ap_parseHTTPdate(const char *date)
        ('S' << 16) | ('e' << 8) | 'p', ('O' << 16) | ('c' << 8) | 't',
        ('N' << 16) | ('o' << 8) | 'v', ('D' << 16) | ('e' << 8) | 'c'};
 
-    if (!date)
+    if (!date)                  /* ZZZ return AP_FAILURE on all errors. */
        return BAD_DATE;
 
     while (*date && ap_isspace(*date)) /* Find first non-whitespace char */
@@ -317,5 +317,7 @@ API_EXPORT(time_t) ap_parseHTTPdate(const char *date)
 
     ds.tm_mon = mon;
 
-    return ap_tm2sec(&ds);
+    /* ZZZ return AP_SUCCESS.  use AP Implode time func for this. */
+    *retval = ap_tm2sec(&ds);
+    return 1;
 }
index 012896d7c24b4726ced9cfbfb2a4c450e2c8b261..4c300d2a292186e020c29a9c15df978bea993fb5 100644 (file)
@@ -588,10 +588,11 @@ API_EXPORT(int) ap_scan_script_header_err_core(request_rec *r, char *buffer,
         * pass it on blindly because of restrictions on future values.
         */
        else if (!strcasecmp(w, "Last-Modified")) {
-           time_t mtime = ap_parseHTTPdate(l);
-
-           ap_update_mtime(r, mtime);
-           ap_set_last_modified(r);
+           time_t mtime;
+           if (ap_parseHTTPdate(l, &mtime) == 1) {
+               ap_update_mtime(r, mtime);
+               ap_set_last_modified(r);
+           }
        }
        else if (!strcasecmp(w, "Set-Cookie")) {
            ap_table_add(cookie_table, w, l);