Permalink
Browse files

Change signature of nginx_send_file to what Merb 0.9.8 is gonna use.

  • Loading branch information...
1 parent 4d3e95d commit 241cb54765d67d1662763071dc641416b0f7f2d7 @michaelklishin committed Sep 17, 2008
Showing with 7 additions and 6 deletions.
  1. +7 −6 app/controllers/files.rb
View
@@ -10,13 +10,14 @@ def image
# This is gonna be in merb-core 0.9.8, version in 0.9.7 does
# not take care of content type and content disposition headers
- # at all so it's not very useful and may be confusing for some
- # people.
- def nginx_send_file(path)
- # Let Nginx detect content type unless it is explicitly set
- headers['Content-Type'] = ""
- headers["Content-Disposition"] = "attachment; filename=#{path.split('/').last}"
+ # at all so it's not very useful and may be confusing for some.
+ def nginx_send_file(path, content_type = "")
+ # Let Nginx detect content type unless it is explicitly set
+ headers['Content-Type'] = content_type
+ headers["Content-Disposition"] ||= "attachment; filename=#{path.split('/').last}"
+
headers['X-Accel-Redirect'] = path
+
return ' '
end
end

0 comments on commit 241cb54

Please sign in to comment.