You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@httpd.apache.org by "Roy T. Fielding" <fi...@kiwi.ICS.UCI.EDU> on 1999/08/26 17:24:46 UTC

reverse 2.0: change to ap_parseHTTPdate

Reminder to self ... reverse this when done mucking with cvs.

------- Forwarded Message

  Modified:    src/include util_date.h
               src/main http_protocol.c util_date.c util_script.c
  Log:
  This evil little change modifies the interface to ap_parseHTTPdate()
  for no good reason.  It'll be backed out real soon.
  
  Submitted by:	pthreads leftovers
  
  Revision  Changes    Path
  1.2       +1 -1      apache-2.0/src/include/util_date.h
  
  Index: util_date.h
  ===================================================================
  RCS file: /home/fielding/moot/apache-2.0/src/include/util_date.h,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- util_date.h	1999/08/24 05:50:48	1.1
  +++ util_date.h	1999/08/26 14:53:20	1.2
  @@ -76,7 +76,7 @@
   
   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
   }
  
  
  
  1.5       +12 -7     apache-2.0/src/main/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/fielding/moot/apache-2.0/src/main/http_protocol.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- http_protocol.c	1999/08/26 14:18:34	1.4
  +++ http_protocol.c	1999/08/26 14:53:22	1.5
  @@ -425,10 +425,12 @@
            */
           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 @@
       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;
           }
       }
  
  
  
  1.2       +5 -3      apache-2.0/src/main/util_date.c
  
  Index: util_date.c
  ===================================================================
  RCS file: /home/fielding/moot/apache-2.0/src/main/util_date.c,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- util_date.c	1999/08/24 06:45:21	1.1
  +++ util_date.c	1999/08/26 14:53:23	1.2
  @@ -214,7 +214,7 @@
    * 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 @@
   	('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 @@
   
       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;
   }
  
  
  
  1.5       +5 -4      apache-2.0/src/main/util_script.c
  
  Index: util_script.c
  ===================================================================
  RCS file: /home/fielding/moot/apache-2.0/src/main/util_script.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- util_script.c	1999/08/26 12:54:16	1.4
  +++ util_script.c	1999/08/26 14:53:24	1.5
  @@ -588,10 +588,11 @@
   	 * 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);
  
  
  

------- End of Forwarded Message