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 << "<p>#{$!}<ul>"
+ $stderr << $!.backtrace.collect {|i| "<li>#{i}</li>"}
+ end
+ end
+
+
+
def Iowa.handleConnection(socket)
urlLen = socket.recv(1)
url = socket.recv(urlLen[0])
***************
*** 85,90 ****
--- 123,137 ----
end
end
+ def Iowa.run2(app_name)
+ require "fcgi"
+ FCGI.each_request do |f|
+ $stderr = f.err
+ handleFCGIConnection(f.in, f.out)
+ end
+ end
+
+
def Iowa.app
if @@app
@@app
Regards,
Michael
--
Michael Neumann
merlin.zwo InfoDesign GmbH
http://www.merlin-zwo.de