# HG changeset patch # User jittat # Date 2009-04-25 04:35:37 # Node ID 400ab663b3b922088bf5b5a0a34962ec0ae6bf98 # Parent 1a5685d096bd1c69f6d6e856412c8521ebdf6e1e added option for Apapche X-Sendfile git-svn-id: http://theory.cpe.ku.ac.th/grader/web/trunk@370 6386c4cd-e34a-4fa8-8920-d93eb39b512e diff --git a/app/controllers/tasks_controller.rb b/app/controllers/tasks_controller.rb --- a/app/controllers/tasks_controller.rb +++ b/app/controllers/tasks_controller.rb @@ -20,15 +20,15 @@ redirect_to :action => 'index' and return end - response.headers['Content-Type'] = "application/force-download" - response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\"" - response.headers["X-Sendfile"] = filename - response.headers['Content-length'] = File.size(filename) - render :nothing => true - - return - - send_file filename, :stream => false, :filename => base_filename + if defined?(USE_APACHE_XSENDFILE) and USE_APACHE_XSENDFILE + response.headers['Content-Type'] = "application/force-download" + response.headers['Content-Disposition'] = "attachment; filename=\"#{File.basename(filename)}\"" + response.headers["X-Sendfile"] = filename + response.headers['Content-length'] = File.size(filename) + render :nothing => true + else + send_file filename, :stream => false, :filename => base_filename + end end protected diff --git a/config/environment.rb.SAMPLE b/config/environment.rb.SAMPLE --- a/config/environment.rb.SAMPLE +++ b/config/environment.rb.SAMPLE @@ -87,3 +87,7 @@ # Uncomment so that the system validates user e-mails # VALIDATE_USER_EMAILS = true + +# Uncomment so that Apache X-Sendfile is used when delivering files +# (e.g., in /tasks/view). +# USE_APACHE_XSENDFILE = true