httpd-apreq-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bram <>
Subject Re: Apache::Cookies vs CGI::Cookies
Date Fri, 22 Apr 2005 20:17:04 GMT

> >> * evaluting the object in string context now calls as_string method
> >>   (as CGI::Cookie does)
> >
> > +1 to the concept.
> Actually I take that back.  In apreq2, string context calls value(),
> which is what I'd rather backport to apreq1 (instead of using as_string).

Are you sure of that? I downloaded libapreq2-2.04_03-dev.tar.gz in it there
is a file called Cookie_pm (in glue/perl/xsbuilder/Apache/Cookie) which has
the following code:

package Apache::Cookie;
use overload '""' => sub { shift->as_string };

Which basiclly means that the as_string function is called, unless if it is
redefined at some other point in the code, which would make maintaining it
really hard (IMHO)...

But anyway, I wasn't really talking about backporting, I was talking about
making the documentation of Apache::Cookie (of libapreq1) true... it has this
line: 'Except for the request object passed to Apache::Cookie::new, the OO
interface is identical to CGI::Cookie.' which is not true unless as_string is
called in string context. (since that is what CGI::Cookie does)... so one of
the two should be updated (either the docs or the code)

The advantage of using as_string over value would be that you could do: print
"Set-Cookie: $cookie"; instead of needing to change it to print "Set-Cookie:
" . $cookie->as_string() (or something similar ofc)...


View raw message