Re: mod_ruby Apache::* tutorial

Mat Schaffer <[email protected]> Mon, 12 Jun 2006 21:54:02 -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.

It looks like the cookie stuff is almost there in Apache::request.   
But if I .each over cookies, the value for each is the string cookie,  
unparsed.  Aside from cookies, I'm still facing a bit of a barrier  
with regards to get/post and sessions (if there are any).

Any advice?  I can see how to get a specific get/post or a list of  
them, but how could I get all of them?
And is there any session support in Apache or WEBrick code that could  
be utilized from within ERb?
-Mat