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