[Nitro] Nitro and Apache.

James Britt james_b at neurogami.com
Sat Oct 22 11:59:12 EDT 2005


James Britt wrote:
> George Moschovitis wrote:
...

> 
> But the Request object has an  'in' attribute; perhaps the cgi.rb code 
> for self.parse_params(context) needs to call 
> "context.request.in.binmode" and read from "context.request.in"
> 
> http://www.nitrohq.com:8090/nitro/lib/nitro/cgi.rb
> 
> I'll see if this actually works.

No, it does not.  Not on .23 at least.

Here's the code I have right now in
/usr/local/lib/ruby/gems/1.8/gems/nitro-0.23.0/lib/nitro/adapter/cgi.rb

(sorry or all the line wrapping.)

#------------ Begin

   def self.parse_params(context)
     method = context.method
     if (:post == method) and
 
%r|\Amultipart/form-data.*boundary=\"?([^\";,]+)\"?|n.match(context.headers['CONTENT_TYPE'])
       boundary = $1.dup
       context.params = parse_multipart(context, boundary)

       # Also include the URL parameters.
 
context.params.update(CgiUtils.parse_query_string(context.query_string))
     else
       case method
       when :get, :head
         context.params = CgiUtils.parse_query_string(context.query_string)
       when :post
         begin
           context.in.binmode #  if defined?(context.in.binmode)
         rescue Exception; end
         begin
           context.params = 
CgiUtils.parse_query_string(context.in.read(context.content_length) || '')
         rescue Exception
           context.params = CgiUtils.parse_query_string( 
context.headers[ 'QUERY_STRING' ] || '')
         end
       end
     end
   end

#------------ End



Is there ever a time when context is expected to have an 'in' attribute 
that behaves as an IO thing?   If not then the begin/rescue hack I'm 
using should just go away, and the code should just grab the query 
string straight from the headers.

James



More information about the Nitro-general mailing list