Sha256: 916e55d127ec47ae983cd9463dfe1e53ee23a7a29c080af670aa59d942b529cb

Contents?: true

Size: 1.1 KB

Versions: 15

Compression:

Stored size: 1.1 KB

Contents

require 'rbconfig'
require 'webrick'

class HTTPServer < WEBrick::HTTPServer
	
		def service(req,res)
			if req.unparsed_uri == "*"
				if req.request_method == "OPTIONS"
					do_OPTIONS(req, res)
					raise ::HTTPStatus::OK
				end
				raise ::HTTPStatus::NotFound, "`#{req.unparsed_uri}' not found."
			end

			servlet = options = script_name = path_info = nil
			servlet, options, script_name, path_info = search_servlet(req.path)
		
			raise ::HTTPStatus::NotFound, "`#{req.path}' not found." unless servlet
			req.script_name = script_name
			req.path_info = path_info
			si = servlet.get_instance(self, *options)
			@logger.debug(format("%s is invoked.", si.class.name))
			si.service(req, res)
		end

end

ruby = File.join(::Config::CONFIG['bindir'],::Config::CONFIG['ruby_install_name'])
ruby << ::Config::CONFIG['EXEEXT']

server = HTTPServer.new(
	:Port => 47990,
	:DocumentRoot => 'doc',
	:CGIInterpreter => ruby)

file_handler_options = {:HandlerTable => Hash.new(WEBrick::HTTPServlet::CGIHandler)}
server.mount('/cgi', WEBrick::HTTPServlet::FileHandler, File.join(Dir.getwd,'cgi'), file_handler_options)
server.start

Version data entries

15 entries across 3 versions & 1 rubygems

Version Path
IOWA-1.0.3 test/TC_NoSubclass/webrick.rb
IOWA-1.0.3 test/TC_Minimal/webrick.rb
IOWA-1.0.3 components/Content/example/webrick.rb
IOWA-1.0.3 test/TC_CGI_Adaptor/webrick.rb
IOWA-1.0.3 test/TC_AppConfig/webrick.rb
IOWA-1.0.2 test/TC_CGI_Adaptor/webrick.rb
IOWA-1.0.2 components/Content/example/webrick.rb
IOWA-1.0.2 test/TC_AppConfig/webrick.rb
IOWA-1.0.2 test/TC_Minimal/webrick.rb
IOWA-1.0.2 test/TC_NoSubclass/webrick.rb
IOWA-1.0.0 components/Content/example/webrick.rb
IOWA-1.0.0 test/TC_NoSubclass/webrick.rb
IOWA-1.0.0 test/TC_Minimal/webrick.rb
IOWA-1.0.0 test/TC_CGI_Adaptor/webrick.rb
IOWA-1.0.0 test/TC_AppConfig/webrick.rb