httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Maurice Aubrey <maur...@hevanet.com>
Subject patch to ignore blank cookie attributes
Date Sat, 08 Dec 2001 02:41:20 GMT
Here's a little patch that makes
ApacheCookie_as_string() ignore blank attributes.

This allows you to do something like this and
not end up with a domain=; value in the cookie:

  my $cookie = Apache::Cookie->new(
    $r,
    -name => 'foo',
    -value => '123',
    -domain => undef,
  );

This is consistent (although not exactly equivalent) to
CGI::Cookie, which includes this in its as_string() method:

  push(@constant_values,"domain=$domain") if $domain = $self->domain;
  push(@constant_values,"path=$path") if $path = $self->path;
  push(@constant_values,"expires=$expires") if $expires = $self->expires;

--- c/apache_cookie.c.orig	Fri Dec  7 18:16:05 2001
+++ c/apache_cookie.c	Fri Dec  7 18:16:32 2001
@@ -188,7 +188,7 @@
     *(char **)ap_push_array(arr) = (char *)val
 
 #define cookie_push_named(arr, name, val) \
-    if(val) { \
+    if(val && (strlen(val) > 0)) { \
         cookie_push_arr(arr, ap_pstrcat(p, name, "=", val, NULL)); \
     }
 

Mime
View raw message