Re: mod_ruby Apache::* tutorial

Mat Schaffer <[email protected]> Fri, 2 Jun 2006 13:46:17 -0400
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
On Jun 2, 2006, at 1:05 PM, Kirk Haines wrote:

> On Friday 02 June 2006 10:36 am, Mat Schaffer wrote:
>
>> Is there anyone working on a cleaner way to access these things?
>> Having to do cookies via manual header lines is a pretty significant
>> barrier to entry, IMHO.
>
> Take a look at WEBrick::Cookie.  It lives under the WEBrick  
> namespace, but is
> not coupled with WEBrick; it can be used independently.
>
> require 'webrick/cookie'
> #
> # misc stuff
> #
> # Set a cookie
> cookie = WEBrick::Cookie.new('user_id','12345')
> cookie.expires = Time.now + (86400 * 30)
> cookie.path = '/'
> request.headers_out['Set-Cookie'] = cookie.to_s
>
> # Read cookies
> cookies = WEBrick::Cookie.parse(request.headers_in['Cookie'])
>
>
> It's a very, very short jump from there to a library encapsulating  
> cookie
> handling for mod_ruby into something simpler, yet.  Extend  
> Apache::Request,
> maybe?
>
> cookies = request.cookies
> request.cookie = cookie
> request.cookie = {:key => 'user_id', :value => @user_id, :path =>
> '/', :expires => Time.now + 86400 * 30}
>
> Something like that.  I'll write it later today if I get less busy,  
> if nobody
> beats me to it.

Lovely! I'm in no time crunch myself.  But I'd love to see it  
happen.   Extending Apache::Request seems like a good start.  Once I  
figure out how to work Apache::Request to get the functionality I'm  
looking for, I'll try to wrap it up into a set of functions that can  
be required at the apache configuration level to produce a PHP-like  
environment.
-Mat