239: def process(request, response)
240: req_method = request.params[Const::REQUEST_METHOD] || Const::GET
241: req_path = can_serve request.params[Const::PATH_INFO]
242: if not req_path
243:
244: response.start(404) do |head,out|
245: out << "File not found"
246: end
247: else
248: begin
249: if File.directory? req_path
250: send_dir_listing(request.params[Const::REQUEST_URI], req_path, response)
251: elsif req_method == Const::HEAD
252: send_file(req_path, request, response, true)
253: elsif req_method == Const::GET
254: send_file(req_path, request, response, false)
255: else
256: response.start(403) {|head,out| out.write(ONLY_HEAD_GET) }
257: end
258: rescue => details
259: STDERR.puts "Error sending file #{req_path}: #{details}"
260: end
261: end
262: end