diff options
Diffstat (limited to 'tool/test/webrick/utils.rb')
-rw-r--r-- | tool/test/webrick/utils.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/tool/test/webrick/utils.rb b/tool/test/webrick/utils.rb index a8568d0a43..c8e84c37f1 100644 --- a/tool/test/webrick/utils.rb +++ b/tool/test/webrick/utils.rb @@ -81,4 +81,24 @@ module TestWEBrick def start_httpproxy(config={}, log_tester=DefaultLogTester, &block) start_server(WEBrick::HTTPProxyServer, config, log_tester, &block) end + + def start_cgi_server(config={}, log_tester=TestWEBrick::DefaultLogTester, &block) + config = { + :CGIInterpreter => TestWEBrick::RubyBin, + :DocumentRoot => File.dirname(__FILE__), + :DirectoryIndex => ["webrick.cgi"], + :RequestCallback => Proc.new{|req, res| + def req.meta_vars + meta = super + meta["RUBYLIB"] = $:.join(File::PATH_SEPARATOR) + meta[RbConfig::CONFIG['LIBPATHENV']] = ENV[RbConfig::CONFIG['LIBPATHENV']] if RbConfig::CONFIG['LIBPATHENV'] + return meta + end + }, + }.merge(config) + if RUBY_PLATFORM =~ /mswin|mingw|cygwin|bccwin32/ + config[:CGIPathEnv] = ENV['PATH'] # runtime dll may not be in system dir. + end + start_server(WEBrick::HTTPServer, config, log_tester, &block) + end end |