The Artima Developer Community
Sponsored Link

Ruby Buzz Forum
One More Fix in output_compression

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Guy Naor

Posts: 104
Nickname: familyguy
Registered: Mar, 2006

Guy Naor is one of the founders of famundo.com and a long time developer
One More Fix in output_compression Posted: Apr 3, 2006 5:36 PM
Reply to this message Reply

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

Advertisement

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

Topic: Como escoger un lenguaje de programación para la empresa: ¡Simple, piense en un ecosistema! Previous Topic   Next Topic Topic: Private constants?

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use