Accessing data from the Apache request in an AuthenHandler destroys it for the content handler?
"Ralph L. Mayo" <[email protected]> Thu, 15 Mar 2007 15:38:33 -0700
| Newsgroups | gmane.comp.apache.mod-ruby |
|---|---|
| Message-ID | <[email protected]> |
------=_Part_43274_7222085.1173998313907
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
With this Apache config:
<VirtualHost modrubytest>
DocumentRoot /var/www/test
RubyRequire test/modrubyauthentest
<Location />
SetHandler ruby-object
RubyAuthenHandler Test::ModRubyAuthenTest.instance
RubyHandler Test::ModRubyAuthenTest.instance
AuthName SomeRealm
AuthType Basic
Require valid-user
Options +ExecCGI
</Location>
</VirtualHost>
and this ruby:
#!/usr/bin/ruby
require 'singleton'
module Test
class ModRubyAuthenTest
include Singleton
def handler(r)
r.content_type = 'text/html'
if r.method_number == Apache::M_GET
puts <<END_HTML
<html>
<body>
<form action="/" method="post">
<input type="hidden" name="foo" value="bar" />
<input type="submit" />
</form>
</body>
</html>
END_HTML
else
puts r.param('foo')
end
return Apache::OK
end
def authenticate(r)
# Uncomment either or both and r.param('foo') in handler() is
nil
#r.param('foo')
#r.cookies
return Apache::OK
end
end
end
Everything works. On GET a page comes up with the submit button, and on POST
it displays 'bar', the value of the hidden input 'foo'. But, if I uncomment
either of the marked lines in authenticate() the output from the same action
is nil (ie, r.param('foo') is nil). The behavior is the same without using
Singleton. I assume this is a bug, as neither line should change any data,
but would be happy to be corrected about any misunderstanding on my part.
Thanks.
ruby 1.8.5 (2006-08-25) [i486-linux]
Server version: Apache/2.2.3
Server built: Jan 15 2007 18:14:50
mod_ruby/1.2.6
------=_Part_43274_7222085.1173998313907
Content-Type: text/html; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
With this Apache config:<br><br><VirtualHost modrubytest><br> DocumentRoot /var/www/test<br> RubyRequire test/modrubyauthentest<br> <br> <Location /><br> SetHandler ruby-object<br> RubyAuthenHandler Test::
ModRubyAuthenTest.instance<br> RubyHandler Test::ModRubyAuthenTest.instance<br> <br> AuthName SomeRealm<br> AuthType Basic<br> Require valid-user<br><br> Options +ExecCGI<br>
</Location><br></VirtualHost><br><br>and this ruby:<br><br>#!/usr/bin/ruby<br><br>require 'singleton'<br><br>module Test<br> class ModRubyAuthenTest<br> include Singleton<br> def handler(r)
<br> r.content_type = 'text/html'<br> if r.method_number == Apache::M_GET<br> puts <<END_HTML<br><html><br><body><br> <form action="/" method="post">
<br> <input type="hidden" name="foo" value="bar" /><br> <input type="submit" /><br> </form><br></body><br></html><br>END_HTML<br> else
<br> puts r.param('foo') <br> end<br> return Apache::OK<br> end<br><br> def authenticate(r)<br> # Uncomment either or both and r.param('foo') in handler() is nil
<br> #r.param('foo')<br> #r.cookies<br> return Apache::OK<br> end<br> end<br>end<br><br>Everything works. On GET a page comes up with the submit button, and on POST it displays 'bar', the value of the hidden input 'foo'. But, if I uncomment either of the marked lines in authenticate() the output from the same action is nil (ie,
r.param('foo') is nil). The behavior is the same without using Singleton. I assume this is a bug, as neither line should change any data, but would be happy to be corrected about any misunderstanding on my part.
<br><br>Thanks.<br><br>ruby 1.8.5 (2006-08-25) [i486-linux]<br>Server version: Apache/2.2.3<br>Server built: Jan 15 2007 18:14:50<br>mod_ruby/1.2.6<br>
------=_Part_43274_7222085.1173998313907--