Re: Accessing POST Data More Than Once

Ben Gribaudo <[email protected]> Tue, 15 Nov 2005 09:46:56 -0600
Newsgroups gmane.comp.apache.mod-ruby
Message-ID <[email protected]>
Maybe I should detail our problem a little more.

Our complex custom templating system requires a file containing a class 
called Page. Depending on the particular configuration of a given page, 
Page can get initialized several times. Page has a method to fetch CGI 
parameters (calls @cgi.params.dup where @cgi has been initialized to 
CGI.new). The first time this method is called, things work. Subsequent 
calls don't work under Ubuntu 5.04/Ruby 1.8. They did under Debian 3.0 
and Ruby1.6.

I tried setting a class variable with cgi.params the first time Page is 
initialized. This didn't work because we're using mod_ruby and Apache2 
which caches code in memory between requests.

Any ideas on a work-around (other than re-writing the template system)?

Ben

Brian Candler wrote:

>On Tue, Nov 15, 2005 at 12:44:28PM +0100, Katarina WONG wrote:
>  
>
>>>I think some people would expect read to work the same here as it does
>>>for all other IO objects.
>>>      
>>>
>>I do not know what you expect but I should think that a rewind is in order
>>if you want to read several times from a stream. Also, I reckon this will
>>not work for all IO instances (seekable streams only).
>>    
>>
>
>I think that was exactly what was meant :-)
>
>You can't rewind the web browser which is sending you POST content - so you
>get one bite at the cherry.
>
>  
>