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