httpd-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Guernsey, Byron \(GE Consumer & Industrial\)" <BYRON.GUERN...@GE.COM>
Subject mod_rewrite cookie patch (PR#28391)
Date Mon, 19 Jul 2004 14:19:13 GMT

Just bringing this one up again and submitting it for anyone who would
like to test.  Attached to this email is a new patch against 2.0.50 that
modifies mod_rewrite.c to support the setting of cookies which have no
domain specified (ie: set to 'null'), or no timeout specified ('null')
or no path specified.  

By definition, a cookie without a domain will be valid for the domain of
the request.

And a cookie without a timeout/expires will be valid for the session of
the browser. 

Both of these features are useful in implementing sticky load balancing
with mod_rewrite. 

Please, if some others can test the patch and use it, I'd certainly love
to have this committed to some future version of http 2.0.  We have been
running the patch here at GE in development for over a month with a
reasonably heavy load.  We're about to move this into production with
httpd 2.0.50. 

I'm willing to submit a documentation patch if we can get this evaluated
for inclusion.  It's a simple change- if you specify "null" for any of
the values for domain, expires, or path in the ':' delimited list used
in the CO rewrite rule, it leaves those values out of the cookie.
"null" must be used as a placeholder to keep the change compatible with
the initial definition of the CO flag.

Byron Guernsey
OS Architect
GE Consumer & Industrial Products

--- mod_rewrite.c.orig  Fri Jun 11 17:05:22 2004
+++ mod_rewrite.c       Mon Jul 12 10:17:31 2004
@@ -4337,6 +4337,12 @@
     }
 }

+static void expand_nullval(char **p) {
+       if(*p == NULL) return;
+
+       if(strcmp(*p, "null") == 0) *p = NULL;
+}
+
 static void add_cookie(request_rec *r, char *s)
 {
     char *var;
@@ -4361,7 +4367,11 @@
             path = NULL;
         }

-        if (var && val && domain) {
+       expand_nullval(&domain);
+       expand_nullval(&expires);
+       expand_nullval(&path);
+
+        if (var && val) {
             /* FIX: use cached time similar to how logging does it */
             request_rec *rmain = r;
             char *notename;
@@ -4376,7 +4386,7 @@
                 cookie = apr_pstrcat(rmain->pool,
                                      var, "=", val,
                                      "; path=", (path)? path : "/",
-                                     "; domain=", domain,
+                                     (domain)?";
domain=":NULL,(domain)?domain:NULL,
                                      (expires)? "; expires=" : NULL,
                                      (expires)?
                                      ap_ht_time(r->pool,

Mime
View raw message