ASPN ActiveState Programmer Network
ActiveState
/ Home / Perl / PHP / Python / Tcl / XSLT /
/ Safari / My ASPN /
Cookbooks | Documentation | Mailing Lists | Modules | News Feeds | Products | User Groups


Recent Messages
List Archives
About the List
List Leaders
Subscription Options

View Subscriptions
Help

View by Topic
ActiveState
.NET Framework
Open Source
Perl
PHP
Python
Tcl
Web Services
XML & XSLT

View by Category
Database
General
SOAP
System Administration
Tools
User Interfaces
Web Programming
XML Programming


MyASPN >> Mail Archive >> ruby-talk
ruby-talk
Re: Using Derrick Pallas' ruby fcgi dispatcher
by Martin Boese other posts by this author
May 9 2008 9:36AM messages near this date
Using Derrick Pallas' ruby fcgi dispatcher | Re: Using Derrick Pallas' ruby fcgi dispatcher
No clue, but I suggest you to add some:

>  $stderr.puts "TEST X: #{cgi.params.inspect}"

...all over that dispatcher script to see where the problem starts (it will 
log to lighttpd's error log).

 I also had many problems with fcgi and lighttpd mainly because it was setting 
different environment variables than other webserver (webrick). To fix this I 
first modify the environment table before I continue and so far I have no 
problems:

>  class CGI
>    class << self
>      def fix_env(ec)
>        if (ec['PATH_INFO'].nil? || ec['PATH_INFO'] == '') then
>           pi =  ec['REQUEST_URI']
>           pi = pi[0..(pi.index('?')-1)] if pi.include?('?')
>           ec['PATH_INFO'] = pi
>        end
> 
>        if (ec['QUERY_STRING'].nil? || ec['QUERY_STRING'] == '') then
>           ec['QUERY_STRING'] = ec['REQUEST_URI'].include?('?') ?
>               ec['REQUEST_URI'].scan(/.?\?(.*)/)[0][0] :
>               ""
>        end
>        ec
>      end
>    end
>  end


... and in the dispatcher you do:

>  FCGI.each_cgi do |cgi|
>    CGI::fix_env(cgi.env_table)


Maybe that helps...


Martin



On Friday 09 May 2008 12:03:19 Kai Krakow wrote:
>  I am trying to use the following dispatcher in lighttpd:
>  http://derrick.pallas.us/ruby-cgi/
> 
>  Code looks fine, and first request looks fine. But subsequent requests
>  to the dispatcher via the webbrowser do not deliver the query
>  parameters in cgi.params - it's just empty. I have to restart lighttpd
>  oder wait for the dispatcher to die to get correct results again.
> 
>  Is there something wrong with the dispatcher? Or with my code. Here's
>  a snippet of my code which is called thru the dispatcher:
> 
>  ---------------------
>  #!/usr/bin/env ruby
> 
>  puts cgi.header
> 
>  require 'yaml'
>  require 'rubygems'
>  require 'active_record'
>  require 'action_mailer'
> 
>  ...
> 
>  puts cgi.params.inspect # <-- debug, it's empty on second request
>  params = cgi.params.select { |q,| %w{system keyword udh smstext
>  absender time client}.include? q }
>  params = Hash[*params.flatten]
>  ---------------------
> 
>  Third last line shows the problem...
> 
>  Any clues?
> 
>  Regards,
>  Kai
Thread:
Kai Krakow
Martin Boese
Kai Krakow
Kai Krakow

Privacy Policy | Email Opt-out | Feedback | Syndication
© 2004 ActiveState, a division of Sophos All rights reserved