Ralph L. Mayo
2007-03-15 22:38:33 UTC
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
<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