httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Chuck Murcko <ch...@hyperreal.com>
Subject cvs commit: apache/src/modules/proxy Makefile mod_proxy.h proxy_cache.c proxy_http.c proxy_util.c
Date Sun, 27 Oct 1996 18:30:01 GMT
chuck       96/10/27 10:30:00

  Modified:    src/modules/proxy  Makefile mod_proxy.h proxy_cache.c
                        proxy_http.c proxy_util.c
  Log:
  Changes to use new util_date.c functions
  
  Revision  Changes    Path
  1.8       +1 -0      apache/src/modules/proxy/Makefile
  
  Index: Makefile
  ===================================================================
  RCS file: /export/home/cvs/apache/src/modules/proxy/Makefile,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -C3 -r1.7 -r1.8
  *** Makefile	1996/10/20 23:58:59	1.7
  --- Makefile	1996/10/27 18:29:55	1.8
  ***************
  *** 83,86 ****
  --- 83,87 ----
    $(OBJS): mod_proxy.h $(INCDIR)/httpd.h $(INCDIR)/http_config.h $(INCDIR)/http_protocol.h
    proxy_cache.o proxy_connect.o proxy_ftp.o proxy_http.o proxy_util.o: $(INCDIR)/http_main.h
    proxy_cache.o proxy_connect.o proxy_http.o: $(INCDIR)/http_log.h
  + proxy_cache.o proxy_http.o: $(INCDIR)/util_date.h
    proxy_cache.o proxy_util.o: $(INCDIR)/md5.h
  
  
  
  1.4       +0 -3      apache/src/modules/proxy/mod_proxy.h
  
  Index: mod_proxy.h
  ===================================================================
  RCS file: /export/home/cvs/apache/src/modules/proxy/mod_proxy.h,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -C3 -r1.3 -r1.4
  *** mod_proxy.h	1996/10/20 23:59:00	1.3
  --- mod_proxy.h	1996/10/27 18:29:56	1.4
  ***************
  *** 265,273 ****
    void proxy_send_headers(BUFF *fp, const char *respline, array_header *hdrs_arr);
    int proxy_liststr(const char *list, const char *val);
    void proxy_hash(const char *it, char *val,int ndepth,int nlength);
  - int proxy_checkmask(const char *data, const char *mask);
  - int proxy_tm2sec(const struct tm *t);
  - int proxy_parsedate(const char *date, struct tm *d);
    int proxy_hex2sec(const char *x);
    void proxy_sec2hex(int t, char *y);
    void proxy_log_uerror(const char *routine, const char *file, const char *err,
  --- 265,270 ----
  
  
  
  1.4       +8 -7      apache/src/modules/proxy/proxy_cache.c
  
  Index: proxy_cache.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_cache.c,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -C3 -r1.3 -r1.4
  *** proxy_cache.c	1996/10/20 23:59:00	1.3
  --- proxy_cache.c	1996/10/27 18:29:56	1.4
  ***************
  *** 57,62 ****
  --- 57,63 ----
    #include "mod_proxy.h"
    #include "http_log.h"
    #include "http_main.h"
  + #include "util_date.h"
    #include <utime.h>
    
    struct gc_ent
  ***************
  *** 272,278 ****
    	close(fd);
    	line[i] = '\0';
    	expire = proxy_hex2sec(line+18);
  ! 	if (!proxy_checkmask(line, "&&&&&&&& &&&&&&&&
&&&&&&&&") ||
    	  expire == -1)
    	{
    	    /* bad file */
  --- 273,279 ----
    	close(fd);
    	line[i] = '\0';
    	expire = proxy_hex2sec(line+18);
  ! 	if (!checkmask(line, "&&&&&&&& &&&&&&&&
&&&&&&&&") ||
    	  expire == -1)
    	{
    	    /* bad file */
  ***************
  *** 341,347 ****
        if (len == 0 || urlbuff[len-1] != '\n') return 0;
        urlbuff[len-1] = '\0';
    
  !     if (!proxy_checkmask(urlbuff,
          "&&&&&&&& &&&&&&&&
&&&&&&&& &&&&&&&& &&&&&&&&"))
    	return 0;
    
  --- 342,348 ----
        if (len == 0 || urlbuff[len-1] != '\n') return 0;
        urlbuff[len-1] = '\0';
    
  !     if (!checkmask(urlbuff,
          "&&&&&&&& &&&&&&&&
&&&&&&&& &&&&&&&& &&&&&&&&"))
    	return 0;
    
  ***************
  *** 428,434 ****
        {
    /* this may modify the value in the original table */
    	imstr = proxy_date_canon(r->pool, imstr);
  ! 	c->ims = proxy_parsedate(imstr, NULL);
    	if (c->ims == -1)  /* bad or out of range date; remove it */
    	    table_set(r->headers_in, "If-Modified-Since", NULL);
        }
  --- 429,435 ----
        {
    /* this may modify the value in the original table */
    	imstr = proxy_date_canon(r->pool, imstr);
  ! 	c->ims = parseHTTPdate(imstr);
    	if (c->ims == -1)  /* bad or out of range date; remove it */
    	    table_set(r->headers_in, "If-Modified-Since", NULL);
        }
  ***************
  *** 582,588 ****
     * read it
     */
        expire = proxy_get_header(resp_hdrs, "Expires");
  !     if (expire != NULL) expc = proxy_parsedate(expire->value, NULL);
        else expc = -1;
    
    /*
  --- 583,589 ----
     * read it
     */
        expire = proxy_get_header(resp_hdrs, "Expires");
  !     if (expire != NULL) expc = parseHTTPdate(expire->value);
        else expc = -1;
    
    /*
  ***************
  *** 591,597 ****
        lmods = proxy_get_header(resp_hdrs, "Last-Modified");
        if (lmods != NULL)
        {
  ! 	lmod = proxy_parsedate(lmods->value, NULL);
    	if (lmod == -1)
    	{
    /* kill last modified date */
  --- 592,598 ----
        lmods = proxy_get_header(resp_hdrs, "Last-Modified");
        if (lmods != NULL)
        {
  ! 	lmod = parseHTTPdate(lmods->value);
    	if (lmod == -1)
    	{
    /* kill last modified date */
  ***************
  *** 636,642 ****
     * Read the date. Generate one if one is not supplied
     */
        dates = proxy_get_header(resp_hdrs, "Date");
  !     if (dates != NULL) date = proxy_parsedate(dates->value, NULL);
        else date = -1;
    	
        now = time(NULL);
  --- 637,643 ----
     * Read the date. Generate one if one is not supplied
     */
        dates = proxy_get_header(resp_hdrs, "Date");
  !     if (dates != NULL) date = parseHTTPdate(dates->value);
        else date = -1;
    	
        now = time(NULL);
  ***************
  *** 671,677 ****
        if (expire == NULL && c->fp != NULL)  /* no expiry data sent in response
*/
        {
    	expire = proxy_get_header(c->hdrs, "Expires");
  ! 	if (expire != NULL) expc = proxy_parsedate(expire->value, NULL);
        }
    /* so we now have the expiry date */
    /* if no expiry date then
  --- 672,678 ----
        if (expire == NULL && c->fp != NULL)  /* no expiry data sent in response
*/
        {
    	expire = proxy_get_header(c->hdrs, "Expires");
  ! 	if (expire != NULL) expc = parseHTTPdate(expire->value);
        }
    /* so we now have the expiry date */
    /* if no expiry date then
  
  
  
  1.5       +2 -1      apache/src/modules/proxy/proxy_http.c
  
  Index: proxy_http.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_http.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -C3 -r1.4 -r1.5
  *** proxy_http.c	1996/10/20 23:59:02	1.4
  --- proxy_http.c	1996/10/27 18:29:57	1.5
  ***************
  *** 55,60 ****
  --- 55,61 ----
    #include "mod_proxy.h"
    #include "http_log.h"
    #include "http_main.h"
  + #include "util_date.h"
    
    /*
     * Canonicalise http-like URLs.
  ***************
  *** 228,234 ****
        }
    
    /* Is it an HTTP/1 response? */
  !     if (proxy_checkmask(buffer,  "HTTP/#.# ### *"))
        {
    /* If not an HTTP/1 messsage or if the status line was > 8192 bytes */
    	if (buffer[5] != '1' || buffer[len-1] != '\n')
  --- 229,235 ----
        }
    
    /* Is it an HTTP/1 response? */
  !     if (checkmask(buffer,  "HTTP/#.# ### *"))
        {
    /* If not an HTTP/1 messsage or if the status line was > 8192 bytes */
    	if (buffer[5] != '1' || buffer[len-1] != '\n')
  
  
  
  1.5       +0 -188    apache/src/modules/proxy/proxy_util.c
  
  Index: proxy_util.c
  ===================================================================
  RCS file: /export/home/cvs/apache/src/modules/proxy/proxy_util.c,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -C3 -r1.4 -r1.5
  *** proxy_util.c	1996/10/20 23:59:03	1.4
  --- proxy_util.c	1996/10/27 18:29:57	1.5
  ***************
  *** 295,312 ****
    /* check date */
        for (mon=0; mon < 12; mon++) if (strcmp(month, months[mon]) == 0) break;
        if (mon == 12) return x;
  - /*
  -  *  it doesn't do any harm to convert an invalid date from one format to
  -  * another
  -  */
  - #if 0
  -     if (hour > 23 || min > 60 || sec > 62 || mday == 0 || mday > 31) return
x;
  -     if (mday == 31 && (mon == 1 || mon == 3 || mon == 5 || mon == 8 || mon ==
10))
  - 	return x;
  -     if (mday > 29 && mon == 1) return x;
  -     if (mday == 29 && mon == 1)
  - 	if (year%4 != 0 || (year%100 == 0 && year%400 != 0)) return x;
  - #endif
    
        if (strlen(x) < 31) x = palloc(p, 31);
        sprintf(x, "%s, %.2d %s %d %.2d:%.2d:%.2d GMT", wday[wk], mday,
  --- 295,300 ----
  ***************
  *** 587,768 ****
    	}
        memcpy(&val[i],&tmp[k],22-k);
        val[i+22-k]='\0';
  - }
  - 
  - /*
  -  * Compare a string to a mask
  -  * Mask characters:
  -  *   @ - uppercase letter
  -  *   # - lowercase letter
  -  *   & - hex digit
  -  *   # - digit
  -  *   * - swallow remaining characters 
  -  *  <x> - exact match for any other character
  -  */
  - int
  - proxy_checkmask(const char *data, const char *mask)
  - {
  -     int i, ch, d;
  - 
  -     for (i=0; mask[i] != '\0' && mask[i] != '*'; i++)
  -     {
  - 	ch = mask[i];
  - 	d = data[i];
  - 	if (ch == '@')
  - 	{
  - 	    if (!isupper(d)) return 0;
  - 	} else if (ch == '$')
  - 	{
  - 	    if (!islower(d)) return 0;
  - 	} else if (ch == '#')
  - 	{
  - 	    if (!isdigit(d)) return 0;
  - 	} else if (ch == '&')
  - 	{
  - 	    if (!isxdigit(d)) return 0;
  - 	} else if (ch != d) return 0;
  -     }
  - 
  -     if (mask[i] == '*') return 1;
  -     else return (data[i] == '\0');
  - }
  - 
  - /*
  -  * This routine converts a tm structure into the number of seconds
  -  * since 1st January 1970 UT
  -  * 
  -  * The return value is a non-negative integer on success or -1 if the
  -  * input date is out of the domain Thu, 01 Jan 1970 00:00:00 to
  -  * Tue, 19 Jan 2038 03:14:07 inclusive
  -  *
  -  * Notes
  -  *   This routine has been tested on 1000000 valid dates generated
  -  *   at random by gmtime().
  -  * 
  -  *   This routine is very fast, much faster than mktime().
  -  */
  - int
  - proxy_tm2sec(const struct tm *t)
  - {
  -     int days, year;
  -     static const int dayoffs[12]=
  -     {306, 337, 0, 31, 61, 92, 122, 153, 184, 214, 245, 275};
  - 
  -     year = t->tm_year;
  - /* shift new year to 1st March; which is where it should be */
  -     if (t->tm_mon < 2) year--;  /* now years and months since 1st March 1900 */
  -     days = t->tm_mday - 1 + dayoffs[t->tm_mon];
  - 
  - /* find the number of days since 1st March 1900 (in the Gregorian calendar) */
  -     days += year * 365 + year/4 - year/100 + (year/100 + 3)/4;
  -     days -= 25508; /* 1 jan 1970 is 25508 days since 1 mar 1900 */
  - 
  -     days = ((days * 24 + t->tm_hour) * 60 + t->tm_min) * 60 + t->tm_sec;
  -     if (year < 69 || year > 138 || days < 0) /* must have overflowed */
  - 	return -1;
  -     else
  - 	return days;
  - }
  - 
  - /*
  -  * Parses a standard HTTP date.
  -  * 
  -  * The restricted HTTP syntax is
  -  *   rfc1123-date = day "," SP 2DIGIT SP date SP time SP "GMT"
  -  *   date = 2DIGIT SP month SP 4DIGIT
  -  *   time = 2DIGIT ":" 2DIGIT ":" 2DIGIT
  -  *
  -  *   day = "Mon" | "Tue" | "Wed" | "Thu" | "Fri" | "Sat" | "Sun"
  -  *
  -  *   month = "Jan" | "Feb" | "Mar" | "Apr" | "May" | "Jun" |
  -  *           "Jul" | "Aug" | "Sep" | "Oct" | "Nov" | "Dec"
  -  *
  -  * The spec is not clear as to whether the day and months are
  -  * case-sensitive or not. This code assumes they are.
  -  *
  -  * It fills in the year, month, mday, hour, min, sec and is_dst fields of
  -  * date. It does not set the wday or yday fields.
  -  * On failure is sets the year to 0.
  -  * 
  -  * It also returns the number of seconds since 1 Jan 1970 UT, or
  -  * -1 if this would be out of range or if the date is invalid.
  -  *
  -  * Notes
  -  *   This routine has been tested on 100000 valid dates generated
  -  *   at random by strftime().
  -  * 
  -  *   This routine is very fast; it would be 10x slower if it
  -  *   used sscanf.
  -  *
  -  * From Andrew Daviel <andrew@vancouver-webpages.com> 29 Jul 96:
  -  *
  -  * Expanded to include RFC850 date (used by Netscape)
  -  *    rfc850-date = weekday "," SP 2DIGIT "-" month "-" 2DIGIT SP time SP "GMT"
  -  * Netscape also appends "; length nnnn" to If-Modified-Since; allow this
  -  *
  -  */
  - int
  - proxy_parsedate(const char *date, struct tm *d)
  - {
  -     int mint, mon, year;
  -     char* comma;
  -     int lday;
  -     struct tm x;
  -     const int months[12]={
  - 	('J' << 16) | ( 'a' << 8) | 'n', ('F' << 16) | ( 'e' << 8) |
'b',
  - 	('M' << 16) | ( 'a' << 8) | 'r', ('A' << 16) | ( 'p' << 8) |
'r',
  - 	('M' << 16) | ( 'a' << 8) | 'y', ('J' << 16) | ( 'u' << 8) |
'n',
  - 	('J' << 16) | ( 'u' << 8) | 'l', ('A' << 16) | ( 'u' << 8) |
'g',
  - 	('S' << 16) | ( 'e' << 8) | 'p', ('O' << 16) | ( 'c' << 8) |
't',
  - 	('N' << 16) | ( 'o' << 8) | 'v', ('D' << 16) | ( 'e' << 8) |
'c'};
  -     if (d == NULL) d = &x;
  - 
  -     d->tm_year = 0;  /* bad date */
  -     comma = strchr(date,',') ;
  -     lday =  (comma-date) ;
  -     
  -     if( lday >= 6 && lday <= 8) {   /* RFC850 */
  -       date = comma - 3 ;
  -       if (!proxy_checkmask(date, "day, ##-@$$-## ##:##:## GMT") && 
  -         !proxy_checkmask(date, "day, ##-@$$-## ##:##:## GMT;*")) return -1;
  -     } else { /* RFC1123 */
  -       if (!proxy_checkmask(date, "@$$, ## @$$ #### ##:##:## GMT") &&
  -         !proxy_checkmask(date, "@$$, ## @$$ #### ##:##:## GMT;*")) return -1;
  -     }
  - 
  - /* we don't test the weekday */
  -     d->tm_mday = (date[5] - '0') * 10 + (date[6] - '0');
  -     if (d->tm_mday == 0 || d->tm_mday > 31) return -1;
  - 
  -     mint = (date[8] << 16) | (date[9] << 8) | date[10];
  -     for (mon=0; mon < 12; mon++) if (mint == months[mon]) break;
  -     if (mon == 12) return -1;
  -     
  -     d->tm_mon = mon;
  -     if( lday >= 6 && lday <= 8) {   /* RFC850 */
  -       year = 1900 + date[12] * 10 + date[13] - ('0' * 11) ;
  -       d->tm_hour = date[15] * 10 + date[16] - '0' * 11;
  -       d->tm_min  = date[18] * 10 + date[19] - '0' * 11;
  -       d->tm_sec = date[21] * 10 + date[22] - '0' * 11;
  -     } else { /* RFC1123 */
  -       year = date[12] * 1000 + date[13] * 100 + date[14] * 10 + date[15] -
  - 	         ('0' * 1111);
  -       d->tm_hour = date[17] * 10 + date[18] - '0' * 11;
  -       d->tm_min  = date[20] * 10 + date[21] - '0' * 11;
  -       d->tm_sec = date[23] * 10 + date[24] - '0' * 11;
  -     }
  - 
  -     if (d->tm_hour > 23 || d->tm_min > 59 || d->tm_sec > 61) return
-1;
  - 
  -     if (d->tm_mday == 31 && (mon == 1 || mon == 3 || mon == 5 || mon == 8 ||
  - 			     mon == 10)) return -1;
  -     if (d->tm_mday > 29 && mon == 1) return -1;
  -     if (d->tm_mday == 29 && mon == 1)
  - 	if (year%4 != 0 || (year%100 == 0 && year%400 != 0)) return -1;
  - 
  -     d->tm_year = year - 1900;
  -     d->tm_isdst = 0;
  -     return proxy_tm2sec(d);
    }
    
    /*
  --- 575,580 ----
  
  
  

Mime
View raw message