Hi,
In message "[ruby-talk:13410] fastcgi troubles"
on 01/04/01, Jilani Khaldi <jilanik / tin.it> writes:
|I am using Fast-cgi ruby module and it works fine, but with "cgi"
|module, when I try to read data (fields) from a HTML pages the following
|code hangs. The code works without using "fcgi".
output should be directed to fcgi.out. I present you the small script
attached gives you little cgi.rb compatibility (note this is a
proof-of-concept toy).
matz.
--- fcgi.rb
require 'CGI'
require 'fcgi.so'
class CGI
class Fast<CGI
CONTINUATION = []
def Fast::new(*args)
at_exit do
if CONTINUATION[0]
CONTINUATION[0].call
end
end
callcc do |c|
CONTINUATION[0] = c
end
fcgi = FCGI::accept
unless fcgi
CONTINUATION[0] = nil
exit
end
$defout = fcgi.out
super(*args)
end
end
end
--- example of usage
#!/usr/local/bin/ruby
require "fcgi.rb"
cgi = CGI::Fast.new
print "Content-type: text/html\n\n"
print "<html><head>"
print "<title> - Guest-book in Ruby - </title>"
print "</head><body>"
print "<h2>Guest-book</h2>"
print "<hr>"
h = cgi.params
ip_address = cgi.remote_addr
name = h["name"].to_s # a field from a HTML page
date = Time.now.asctime
print "<br>"
print "Name: ", name
print "<br>"
print "IP address: ", ip_address
print "<br>"
print "Visit date: ", date
print "<br>"
print "</body></html>"