Re: [Maypole] Maypole::Utils for portability

From: Simon Flack (sf at flacks.net)
Date: Sat Sep 11 2004 - 18:48:29 BST


On Sat, 11 Sep 2004 19:36:14 +0200, Sebastian Riedel wrote
> Simon Flack:
>
> >
> >We could do, but I don't think we need to reinvent tested modules that are
> >already on CPAN. Despite being in the CGI:: namespace, CGI::Cookie isn't
> >dependent on CGI or mod_perl or any other environment. A new maypole
provider
> >just needs to create CGI::Cookie objects or do nothing if cookies aren't
> >available. We could also use HTTP::Headers to represent the output headers.
> >
> >I've attached a patch to demonstrate. It's untested, but should work like
> >this:
> >
> > $r->headers->content_type('text/plain');
> > $r->headers->expires(...);
> > $r->headers->header('X-Bender', 'kiss my shiny metal ass');
> >
> I like it, but how would you handle input headers?

I'm not sure. Perhaps there should be a headers_in() and headers_out(). I
don't really like $r->headers->header() either. I suppose you could do
$r->headers->push_header() or init_header(). It would be better if it were
$r->headers->set or $r->headers->add. Maybe there is a case for a Maypole::
Headers wrapper around HTTP::Headers.

> > $r->cookie()->{foo} = CGI::Cookie->new(-name => 'foo' -value => 'bar');
> > my $user_prefs = $r->cookie()->{user_prefs};
> > print $user_prefs->value;
> >
> >
> Having to type foo twice is a liddle bit annoying and incoming
> cookies will also be send out.

Agreed. $r->cookie()->add() / set() / get() might be nicer. Perhaps there's a
case for a Maypole::Cookie wrapper too. Is it bad if incoming cookies are also
sent out? I imagine that's what you'd want most of the time.

> >The headers() object and cookie() hash is initialised by Maypole.pm in
> >handler(). So maypole providers just need to populate cookies() if
applicable,
> >and handle the headers and cookies in send_output().
> >
> >
> but looks like a good start...
>
> sebastian
>
> _______________________________________________
> maypole mailing list
> maypole at lists.netthink.co.uk
> http://lists.netthink.co.uk/listinfo/maypole

--simonflk

_______________________________________________
maypole mailing list
maypole at lists.netthink.co.uk
http://lists.netthink.co.uk/listinfo/maypole



This archive was generated by hypermail 2.1.3 : Thu Feb 24 2005 - 22:25:56 GMT