httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From c...@apache.org
Subject cvs commit: apache-1.3/src/modules/standard mod_usertrack.c
Date Wed, 15 Aug 2001 21:45:41 GMT
coar        01/08/15 14:45:41

  Modified:    src/modules/standard mod_usertrack.c
  Log:
  	The last commit got away from me; this explains both.  First, make
  	the CookeExpires directive an OR_FILEINFO one like all the others.
  	Next, add a CookieDomain directive so the Domain= attribute may be
  	customised.  Next, add a CookieStyle directive so that the syntax
  	of the cookie may be set.  Historically we have always used the
  	obsolete Netscape syntax, and this is still the default.  However,
  	CookieStyle allows the RFC2109 syntax (essentially Max-Age instead
  	of Expires) or RFC2965 ([Set-]Cookie2) syntax to be used.
  
  PR:		5006, 5023, 5920, 6140
  
  Revision  Changes    Path
  1.50      +37 -14    apache-1.3/src/modules/standard/mod_usertrack.c
  
  Index: mod_usertrack.c
  ===================================================================
  RCS file: /home/cvs/apache-1.3/src/modules/standard/mod_usertrack.c,v
  retrieving revision 1.49
  retrieving revision 1.50
  diff -u -u -r1.49 -r1.50
  --- mod_usertrack.c	2001/08/15 21:12:04	1.49
  +++ mod_usertrack.c	2001/08/15 21:45:41	1.50
  @@ -196,8 +196,12 @@
   
       if (cls->expires) {
           struct tm *tms;
  -        time_t when = r->request_time + cls->expires;
  +        time_t when;
   
  +        when = cls->expires;
  +        if ((dcfg->style == CT_UNSET) || (dcfg->style == CT_NETSCAPE)) {
  +            when += r->request_time;
  +
   #ifndef MILLENIAL_COOKIES
           /*
            * Only two-digit date string, so we can't trust "00" or more.
  @@ -208,18 +212,27 @@
           if (when > 946684799)
               when = 946684799;
   #endif
  +        }
           tms = gmtime(&when);
   
           /* Cookie with date; as strftime '%a, %d-%h-%y %H:%M:%S GMT' */
  -        new_cookie = ap_psprintf(r->pool,
  -                                 "%s=%s; "
  -                                 "path=/; "
  -                                 "expires=%s, %.2d-%s-%.2d %.2d:%.2d:%.2d GMT",
  -                                 dcfg->cookie_name, cookiebuf,
  -                                 ap_day_snames[tms->tm_wday],
  -                                 tms->tm_mday, ap_month_snames[tms->tm_mon],
  -                                 tms->tm_year % 100,
  -                                 tms->tm_hour, tms->tm_min, tms->tm_sec);
  +        new_cookie = ap_psprintf(r->pool, "%s=%s; path=/",
  +                                 dcfg->cookie_name, cookiebuf);
  +        if ((dcfg->style == CT_UNSET) || (dcfg->style == CT_NETSCAPE)) {
  +            new_cookie = ap_psprintf(r->pool, "%s; "
  +                                     "expires=%s, %.2d-%s-%.2d "
  +                                     "%.2d:%.2d:%.2d GMT",
  +                                     new_cookie,
  +                                     ap_day_snames[tms->tm_wday],
  +                                     tms->tm_mday,
  +                                     ap_month_snames[tms->tm_mon],
  +                                     tms->tm_year % 100,
  +                                     tms->tm_hour, tms->tm_min, tms->tm_sec);
  +        }
  +        else {
  +            new_cookie = ap_psprintf(r->pool, "%s; max-age=%d",
  +                                     new_cookie, (int) when);
  +        }
       }
       else {
   	new_cookie = ap_psprintf(r->pool, "%s=%s; path=/",
  @@ -229,8 +242,13 @@
           new_cookie = ap_psprintf(r->pool, "%s; domain=%s",
                                    new_cookie, dcfg->cookie_domain);
       }
  +    if (dcfg->style == CT_COOKIE2) {
  +        new_cookie = ap_pstrcat(r->pool, new_cookie, "; version=1", NULL);
  +    }
   
  -    ap_table_setn(r->headers_out, "Set-Cookie", new_cookie);
  +    ap_table_setn(r->headers_out,
  +                  (dcfg->style == CT_COOKIE2 ? "Set-Cookie2" : "Set-Cookie"),
  +                  new_cookie);
       ap_table_setn(r->notes, "cookie", ap_pstrdup(r->pool, cookiebuf));   /* log first
time */
       return;
   }
  @@ -246,7 +264,10 @@
           return DECLINED;
       }
   
  -    if ((cookie = ap_table_get(r->headers_in, "Cookie")))
  +    if ((cookie = ap_table_get(r->headers_in,
  +                               (dcfg->style == CT_COOKIE2
  +                                ? "Cookie2"
  +                                : "Cookie"))))
           if ((value = strstr(cookie, dcfg->cookie_name))) {
               char *cookiebuf, *cookieend;
   
  @@ -410,10 +431,12 @@
       if (strcasecmp(name, "Netscape") == 0) {
           dcfg->style = CT_NETSCAPE;
       }
  -    else if (strcasecmp(name, "Cookie") == 0) {
  +    else if ((strcasecmp(name, "Cookie") == 0)
  +             || (strcasecmp(name, "RFC2109") == 0)) {
           dcfg->style = CT_COOKIE;
       }
  -    else if (strcasecmp(name, "Cookie2") == 0) {
  +    else if ((strcasecmp(name, "Cookie2") == 0)
  +             || (strcasecmp(name, "RFC2965") == 0)) {
           dcfg->style = CT_COOKIE2;
       }
       else {
  
  
  

Mime
View raw message