|
This post originated from an RSS feed registered with Ruby Buzz
by Guy Naor.
|
Original Post: One More Fix in output_compression
Feed Title: Famundo - The Dev Blog
Feed URL: http://devblog.famundo.com/xml/rss/feed.xml
Feed Description: A blog describing the development and related technologies involved in creating famundo.com - a family management sytem written using Ruby On Rails and postgres
|
Latest Ruby Buzz Posts
Latest Ruby Buzz Posts by Guy Naor
Latest Posts From Famundo - The Dev Blog
|
|
Working with the newly fixed output_compression for Rails 1.1, one of the developers in my team discovered that it breaks send_file() support.
The reason that happens, is that send_file() write directly to the output stream in chunks (4096 bytes be default) and so the compression will fail miserably on it.
The solution is pretty simple - as send_file() set the Content-Disposition HTML header while regular rails output doesn't, I simply disabled compression of any output with a Content-Disposition header.
The fixed file is now available for download here. Or just change the code as follows (in diff -u format):
--- output_compression.rb 2006-03-29 13:37:37.000000000 -0800
+++ output_compression.rb 2006-04-03 15:41:54.000000000 -0700
@@ -18,6 +18,7 @@
def self.filter(controller)
return if COMPRESSION_DISABLED ||
controller.response.headers['Content-Encoding'] ||
+ controller.response.headers['Content-Disposition'] ||
controller.request.env['HTTP_ACCEPT_ENCODING'].nil? ||
controller.component_request?
begin
The important line is:
controller.response.headers['Content-Disposition'] ||
Which checks if the Content-Disposition header was added.
Enjoy!
Read: One More Fix in output_compression