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>&lt;VirtualHost modrubytest&gt;<br>&nbsp;&nbsp;&nbsp; DocumentRoot /var/www/test<br>&nbsp;&nbsp;&nbsp; RubyRequire test/modrubyauthentest<br>&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &lt;Location /&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; SetHandler ruby-object<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RubyAuthenHandler Test::
ModRubyAuthenTest.instance<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; RubyHandler&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Test::ModRubyAuthenTest.instance<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AuthName SomeRealm<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; AuthType Basic<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Require valid-user<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; Options +ExecCGI<br>
&nbsp;&nbsp;&nbsp; &lt;/Location&gt;<br>&lt;/VirtualHost&gt;<br><br>and this ruby:<br><br>#!/usr/bin/ruby<br><br>require &#39;singleton&#39;<br><br>module Test<br>&nbsp;&nbsp;&nbsp; class ModRubyAuthenTest<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; include Singleton<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; def handler(r)
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; r.content_type = &#39;text/html&#39;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; if r.method_number == Apache::M_GET<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; puts &lt;&lt;END_HTML<br>&lt;html&gt;<br>&lt;body&gt;<br>&nbsp;&nbsp;&nbsp; &lt;form action=&quot;/&quot; method=&quot;post&quot;&gt;
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;hidden&quot; name=&quot;foo&quot; value=&quot;bar&quot; /&gt;<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &lt;input type=&quot;submit&quot; /&gt;<br>&nbsp;&nbsp;&nbsp; &lt;/form&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>END_HTML<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; else
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; puts r.param(&#39;foo&#39;)&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return Apache::OK<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; end<br><br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; def authenticate(r)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; # Uncomment either or both and r.param(&#39;foo&#39;) in handler() is nil
<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #r.param(&#39;foo&#39;)<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; #r.cookies<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; return Apache::OK<br>&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; end<br>&nbsp;&nbsp;&nbsp; end<br>end<br><br>Everything works. On GET a page comes up with the submit button, and on POST it displays &#39;bar&#39;, the value of the hidden input &#39;foo&#39;.&nbsp; But, if I uncomment either of the marked lines in authenticate() the output from the same action is nil (ie, 
r.param(&#39;foo&#39;) is nil).&nbsp; The behavior is the same without using Singleton.&nbsp; 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:&nbsp;&nbsp; Jan 15 2007 18:14:50<br>mod_ruby/1.2.6<br>

------=_Part_43274_7222085.1173998313907--