Class: SendFile

Inherits:
Object
  • Object
show all
Includes:
Mongrel::HttpHandlerPlugin
Defined in:
lib/mongrel_send_file/init.rb

Instance Method Summary collapse

Instance Method Details

#process(request, response) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/mongrel_send_file/init.rb', line 7

def process(request, response)
  files = find_session(request)
  files.each do |hash, args|
    files.delete(hash) if args.first < Time.now.utc.to_i
  end
  
  pieces = request.params['PATH_INFO'].split('/')
  pieces.pop # filename
  hash = pieces.pop
  if files[hash].nil?
    response.start(404){}
  else
    send_file(files[hash][1], files[hash][2], response)
  end
end