From: Michael Neumann Date: 2004-05-25T05:48:09+09:00 Subject: Re: Webrick & HOWTO type docs? --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: inline On Tue, May 25, 2004 at 05:12:24AM +0900, Kirk Haines wrote: > I think I know the answer to this already, but.... > > Are there any not-so-easy-to-find documents anywhere on using Webrick? API > docs or howto docs or anything like that? > > I'm going to make Iowa capable of using webrick so that an Iowa application > can be a completely standalone application server. From what I can tell, I wrote such a thing for Iowa 0.14a (it's appended). Don't know if it still works with the current Iowa release. Regards, Michael --cWoXeonUoKmBZSoM Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="webrick-adaptor.rb" require 'webrick' require "socket" require "iowa/config" class IOWAServlet < WEBrick::HTTPServlet::AbstractServlet def service(req, res) url, = req.request_uri.to_s.split("?") params = if req.request_method == "GET" req.query_string || "" else req.body end url =~ ".*?/iowa/([^/]*)" socket_name = "#{$tempDir}iowa_#{$1}" socket = UNIXSocket.new(socket_name) socket.putc(url.length) socket.write(url) socket.putc(params.length) socket.write(params) socket.shutdown(1) body = "" while (recv = socket.recv(1000)) != "" do body << recv end res['Content-type'] = "text/html" res.body = body end end if __FILE__ == $0 s = WEBrick::HTTPServer.new( :Port => 2000, :DocumentRoot => '/home/michael/htdocs', :Logger => WEBrick::Log::new($stderr, WEBrick::Log::DEBUG) ) s.mount("/iowa", IOWAServlet) trap("INT"){ s.shutdown } s.start end --cWoXeonUoKmBZSoM--