I am trying to use sendfile to send files and am using the :x_sendfile => true option. I am experiencing problem that the content length of any file is truncated to 1 byte. The problem appears to be well documented - there is even a fix described here - http://dev.rubyonrails.org/ticket/7643. I migrated my app to Rails 2.1 and still the problem exists. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Reid MacDonald
2008-Jun-13 17:33 UTC
Re: looking for fix to content-length = 1 byte with x_sendfile
As a (stopgap) solution you can add this code (to an initializer, lib, environment.rb): # Does not allow for manually set Content-Length to be overriden (adds ||= instead of =) class ActionController::AbstractResponse private def set_content_length! self.headers["Content-Length"] ||= body.size unless body.respond_to?(:call) end end This will use any pre-existing Content-Length first if there is one. reid On Jun 4, 8:41 am, jamie <jamie.alexan...-bJEeYj9oJeDQT0dZR+AlfA@public.gmane.org> wrote:> I am trying to use sendfile to send files and am using the :x_sendfile > => true option. I am experiencing problem that the content length of > any file is truncated to 1 byte. The problem appears to be well > documented - there is even a fix described here -http://dev.rubyonrails.org/ticket/7643. > I migrated my app to Rails 2.1 and still the problem exists.--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---