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