httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bri...@apache.org
Subject cvs commit: httpd-2.0/modules/http http_protocol.c
Date Sun, 21 Apr 2002 07:55:51 GMT
brianp      02/04/21 00:55:51

  Modified:    include  util_time.h
               server   util_time.c
               modules/http http_protocol.c
  Log:
  Added ap_recent_rfc822_date(), which uses the recent timestamp cache
  
  Revision  Changes    Path
  1.6       +7 -0      httpd-2.0/include/util_time.h
  
  Index: util_time.h
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/include/util_time.h,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- util_time.h	21 Mar 2002 10:10:40 -0000	1.5
  +++ util_time.h	21 Apr 2002 07:55:50 -0000	1.6
  @@ -109,6 +109,13 @@
    */
   AP_DECLARE(apr_status_t) ap_recent_ctime(char *date_str, apr_time_t t);
   
  +/**
  + * format a recent timestamp in the RFC822 format
  + * @param date_str String to write to (must have length >= APR_RFC822_DATE_LEN)
  + * @param t the time to convert 
  + */
  +AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t);
  +
   #ifdef __cplusplus
   }
   #endif
  
  
  
  1.8       +60 -0     httpd-2.0/server/util_time.c
  
  Index: util_time.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/server/util_time.c,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- util_time.c	13 Apr 2002 12:02:38 -0000	1.7
  +++ util_time.c	21 Apr 2002 07:55:50 -0000	1.8
  @@ -218,3 +218,63 @@
   
       return APR_SUCCESS;
   }
  +
  +static const char month_snames[12][4] =
  +{
  +    "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
  +};
  +static const char day_snames[7][4] =
  +{
  +    "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"
  +};
  +
  +AP_DECLARE(apr_status_t) ap_recent_rfc822_date(char *date_str, apr_time_t t)
  +{
  +    /* ### This code is a clone of apr_rfc822_date(), except that it
  +     * uses ap_explode_recent_gmt() instead of apr_time_exp_gmt().
  +     */
  +    apr_time_exp_t xt;
  +    const char *s;
  +    int real_year;
  +
  +    ap_explode_recent_gmt(&xt, t);
  +
  +    /* example: "Sat, 08 Jan 2000 18:31:41 GMT" */
  +    /*           12345678901234567890123456789  */
  +
  +    s = &day_snames[xt.tm_wday][0];
  +    *date_str++ = *s++;
  +    *date_str++ = *s++;
  +    *date_str++ = *s++;
  +    *date_str++ = ',';
  +    *date_str++ = ' ';
  +    *date_str++ = xt.tm_mday / 10 + '0';
  +    *date_str++ = xt.tm_mday % 10 + '0';
  +    *date_str++ = ' ';
  +    s = &month_snames[xt.tm_mon][0];
  +    *date_str++ = *s++;
  +    *date_str++ = *s++;
  +    *date_str++ = *s++;
  +    *date_str++ = ' ';
  +    real_year = 1900 + xt.tm_year;
  +    /* This routine isn't y10k ready. */
  +    *date_str++ = real_year / 1000 + '0';
  +    *date_str++ = real_year % 1000 / 100 + '0';
  +    *date_str++ = real_year % 100 / 10 + '0';
  +    *date_str++ = real_year % 10 + '0';
  +    *date_str++ = ' ';
  +    *date_str++ = xt.tm_hour / 10 + '0';
  +    *date_str++ = xt.tm_hour % 10 + '0';
  +    *date_str++ = ':';
  +    *date_str++ = xt.tm_min / 10 + '0';
  +    *date_str++ = xt.tm_min % 10 + '0';
  +    *date_str++ = ':';
  +    *date_str++ = xt.tm_sec / 10 + '0';
  +    *date_str++ = xt.tm_sec % 10 + '0';
  +    *date_str++ = ' ';
  +    *date_str++ = 'G';
  +    *date_str++ = 'M';
  +    *date_str++ = 'T';
  +    *date_str++ = 0;
  +    return APR_SUCCESS;
  +}
  
  
  
  1.413     +3 -2      httpd-2.0/modules/http/http_protocol.c
  
  Index: http_protocol.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/http/http_protocol.c,v
  retrieving revision 1.412
  retrieving revision 1.413
  diff -u -r1.412 -r1.413
  --- http_protocol.c	18 Apr 2002 22:50:54 -0000	1.412
  +++ http_protocol.c	21 Apr 2002 07:55:50 -0000	1.413
  @@ -89,6 +89,7 @@
   #include "apr_date.h"           /* For apr_date_parse_http and APR_DATE_BAD */
   #include "util_charset.h"
   #include "util_ebcdic.h"
  +#include "util_time.h"
   
   #include "mod_core.h"
   
  @@ -1071,7 +1072,7 @@
       apr_brigade_write(bb, NULL, NULL, tmp, len);
   
       date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
  -    apr_rfc822_date(date, r->request_time);
  +    ap_recent_rfc822_date(date, r->request_time);
   
       h.pool = r->pool;
       h.bb = bb;
  @@ -1444,7 +1445,7 @@
        */
       if (r->no_cache && !apr_table_get(r->headers_out, "Expires")) {
           char *date = apr_palloc(r->pool, APR_RFC822_DATE_LEN);
  -        apr_rfc822_date(date, r->request_time);
  +        ap_recent_rfc822_date(date, r->request_time);
           apr_table_addn(r->headers_out, "Expires", date);
       }
   
  
  
  

Mime
View raw message