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