Index: [Article Count Order] [Thread]

Date: Tue, 02 Sep 2003 19:01:48 +0900 (JST)
From: GOTOU Yuuzou <gotoyuzo@notwork.org>
Subject: [webricken:119] Re: Getting cgi scripts to work
To: webricken@notwork.org
Message-Id: <20030902.190148.629461786.gotoyuzo@kotetsu.does.notwork.org>
In-Reply-To: <AC803256-DAED-11D7-B360-000393876156@cox.net>
References: <AC803256-DAED-11D7-B360-000393876156@cox.net>
X-Mail-Count: 00119

Hi,

In message <AC803256-DAED-11D7-B360-000393876156@cox.net>,
 `Mark Wilson <mwilson13@cox.net>' wrote:
> I'll show code and output to describe the problem I'm having. I'm aware 
> that my problem may be with web servers generally and not webrick 
> specifically, but I still need help.

CGIHandler is invoked by FileHandler.  When FileHander was
connected to a directory by HTTPServer#mount, the files on
the directory will be processed by handler accorded with the
file type.

If you want to process every file under specified directory
by CGIHandler, :HandlerTable option (for FileHandler) can be
used.

  require 'webrick'
  include WEBrick

  docroot = File::join(Dir::pwd, "htdocs")
  cgibin  = File::join(docroot, "cgi-bin")
  s = HTTPServer.new(:Port => 2000, :DocumentRoot => docroot)

  # :HandlerTable is a Hash to take a handler appropriate to
  # suffix of file. (For /cgi-bin directory, use CGIHandler
  # as default.)
  file_handler_opt = { :HandlerTable => Hash.new(HTTPServlet::CGIHandler) }
  s.mount("/cgi-bin", HTTPServlet::FileHandler, cgibin, file_handler_opt)

  trap("INT") { s.shutdown }
  s.start

-- 
gotoyuzo