From: Michael Neumann Date: 2001-07-17T21:33:32+09:00 Subject: [ruby-talk:17990] Re: FastCGI for Ruby? Michael Neumann wrote: > I've patched the latest IOWA to work with FastCGI. *** iowa.rb Sun Feb 11 08:18:31 2001 --- ../myiowa/iowa.rb Sat Jul 7 11:30:49 2001 *************** *** 38,43 **** --- 38,81 ---- @@app = nil + + def Iowa.handleFCGIConnection(input, output) + url, junk = ENV["REQUEST_URI"].split("?") + if ENV["REQUEST_METHOD"] == "GET" + query = ENV["QUERY_STRING"] + else + query = input.read(ENV["CONTENT_LENGTH"].to_i) + end + + $stderr << "REQUEST_URI: #{ENV['REQUEST_URI']}\n" + $stderr << "QUERY_STRING: #{ENV['QUERY_STRING']}\n" + + output << "Content-type: text/html\r\n\r\n" + + params = {} + query.split(/[&;]/).each do |x| + key, val = x.split(/=/,2).collect{|x| unescape(x)} + if params.include?(key) + params[key] += "\0" + (val or "") + else + params[key] = (val or "") + end + end + + begin + stream = BufferedStream.new(output) + + context = Iowa::Context.new(url, params, stream) + app.handleRequest(context) + stream.flush + rescue Exception + $stderr << "

#{$!}