def process(request, response)
req_method = request.params[Const::REQUEST_METHOD] || Const::GET
req_path = can_serve request.params[Const::PATH_INFO]
if not req_path
response.start(404) do |head,out|
out << "File not found"
end
else
begin
if File.directory? req_path
send_dir_listing(request.params[Const::REQUEST_URI], req_path, response)
elsif req_method == Const::HEAD
send_file(req_path, request, response, true)
elsif req_method == Const::GET
send_file(req_path, request, response, false)
else
response.start(403) {|head,out| out.write(ONLY_HEAD_GET) }
end
rescue => details
STDERR.puts "Error sending file #{req_path}: #{details}"
end
end
end