]> granicus.if.org Git - apache/commitdiff
set expiry time correctly.
authorIan Holsman <ianh@apache.org>
Thu, 29 Aug 2002 22:45:13 +0000 (22:45 +0000)
committerIan Holsman <ianh@apache.org>
Thu, 29 Aug 2002 22:45:13 +0000 (22:45 +0000)
set Cookie on err_headers_out, and ensure it is only set once.

PR: 12132
Submitted by: apachecvslog@robcromwell.com (Rob Cromwell)

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@96577 13f79535-47bb-0310-9956-ffa450edef68

CHANGES
modules/mappers/mod_rewrite.c

diff --git a/CHANGES b/CHANGES
index bb3159dc9361bb73e25cb114c6d437d5d32beba0..cc00f63c74c6c89ef781e17017603ea72b3e8482 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,5 +1,9 @@
 Changes with Apache 2.0.41
 
+  *) mod_rewrite can now sets cookies in err_headers, and uses the correct
+     expiry date. PR 12132 
+     [Ian Holsman / Rob Cromwell <apachechangelog@robcromwell.com>]
+
   *) The content-length filter no longer tries to buffer up
      the entire output of a long-running request before sending
      anything to the client.  [Brian Pane]
index 0e2d014f365b8349867caac13516eb657cd5d741..16e01e19a418cb3f1c59ecb746d5f4946b9f860f 100644 (file)
@@ -4147,27 +4147,42 @@ static void add_cookie(request_rec *r, char *s)
 
         if (var && val && domain) {
             /* FIX: use cached time similar to how logging does it */
-            cookie = apr_pstrcat( r->pool, 
-                                  var,
-                                  "=",
-                                  val,
-                                  "; path=/; domain=",
-                                  domain,
-                                  (expires)? "; expires=" : NULL,
-                                  (expires)? ap_ht_time(r->pool, 
-                                                        r->request_time + 
-                                                        (60 * atol(expires)),
-                                                         "%a, %d-%b-%Y %T GMT", 1)
-                                           : NULL, 
-                                  NULL);
-
+            request_rec *rmain = r;
+            char *notename;
+            char *data;
+            while (rmain->main) {
+                rmain = rmain->main;
+            }
             
-            /* 
-             * XXX: should we add it to err_headers_out as well ?
-             * if we do we need to be careful that only ONE gets sent out
-             */
-            apr_table_add(r->headers_out, "Set-Cookie", cookie);
-            rewritelog(r, 5, "setting cookie '%s' to '%s'", var, val);
+            notename = apr_pstrcat(rmain->pool, var, "_rewrite", NULL);
+            apr_pool_userdata_get( &data, notename, rmain->pool);
+            if  (data== NULL) {
+               cookie = apr_pstrcat(rmain->pool, 
+                                    var,
+                                    "=",
+                                    val,
+                                    "; path=/; domain=",
+                                    domain,
+                                    (expires)? "; expires=" : NULL,
+                                    (expires)? 
+                                     ap_ht_time(r->pool, 
+                                                r->request_time + 
+                                                apr_time_from_sec((60 *
+                                                               atol(expires))),
+                                                "%a, %d-%b-%Y %T GMT", 1)
+                                           : NULL, 
+                                  NULL);                   
+                /* 
+                * XXX: should we add it to err_headers_out as well ?
+                * if we do we need to be careful that only ONE gets sent out
+                */
+                apr_table_add(rmain->err_headers_out, "Set-Cookie", cookie);
+                apr_pool_userdata_set("set", notename, NULL, rmain->pool);
+                rewritelog(rmain, 5, "setting cookie '%s' to '%s'", var, val);
+            }
+            else {
+                rewritelog(rmain, 5, "cookie '%s' is already set..skipping", var);
+            }
         }
     }
 }