]> git.ipfire.org Git - thirdparty/apache/httpd.git/commitdiff
The last commit got away from me; this explains both. First, make
authorKen Coar <coar@apache.org>
Wed, 15 Aug 2001 21:45:41 +0000 (21:45 +0000)
committerKen Coar <coar@apache.org>
Wed, 15 Aug 2001 21:45:41 +0000 (21:45 +0000)
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

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/branches/1.3.x@90175 13f79535-47bb-0310-9956-ffa450edef68

src/modules/standard/mod_usertrack.c

index 51342d873f8389062a0817784183d3dea0035ec4..cc7e5403ef7070c90edba55788cb5b3139326dba 100644 (file)
@@ -196,7 +196,11 @@ static void make_cookie(request_rec *r)
 
     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
         /*
@@ -208,18 +212,27 @@ static void make_cookie(request_rec *r)
         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 @@ static void make_cookie(request_rec *r)
         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 @@ static int spot_cookie(request_rec *r)
         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 @@ static const char *set_cookie_style(cmd_parms *cmd, void *mconfig, char *name)
     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 {