mod_ruby Apache2 Accessing POSTed Data More than Once

B

Ben Gribaudo

(Moving the below over from mod_ruby to the larger audience on ruby-talk.)
Hi,

Our complex custom template 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(libapache2-mod-ruby
1.2.4-1)/Apache2. They did under Debian 3.0/Ruby1.6/Apahce1.3.

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.

Digging down to the mod_ruby level (bypassing CGI):
If I submit data using the example below, the first Apache.request.read
returns the POSTed data while subsequent calls return nil instead of
repeating the POSTed data. So, we get the same problem as we do with CGI.

Using multiple instances of CGI or directly via mod_ruby, how do I
access POSTed data more than one time from a script?

Thank you,
Ben Gribaudo

<pre>
<%
puts Apache.request.read # expected data
puts Apache.request.read # nil
puts Apache.request.read # nil
%>
</pre>
<form method="post">
<input type="text" name="test" />
<input type="submit" />
</form>
 
J

James Britt

Ben Gribaudo wrote:
..
Using multiple instances of CGI or directly via mod_ruby, how do I
access POSTed data more than one time from a script?


Here's a guess: request.reset

I have no means to test this, but maybe request is acting like an IO
object which must be reset after a read.

James

--

http://www.ruby-doc.org - Ruby Help & Documentation
http://www.artima.com/rubycs/ - Ruby Code & Style: Writers wanted
http://www.rubystuff.com - The Ruby Store for Ruby Stuff
http://www.jamesbritt.com - Playing with Better Toys
http://www.30secondrule.com - Building Better Tools
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top