I''m having trouble playing a video from my site on the iphone using send_file. It seems that I''m missing the Accept-Ranges header in my response. How can I set the Accept-Ranges header in my send_file response? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I actually was able to edit the source of rails to get this implemented: vendor/rails/actionpack/lib/action_controller/streaming.rb def send_file_headers!(options) options.update(DEFAULT_SEND_FILE_OPTIONS.merge(options)) [:length, :type, :disposition].each do |arg| raise ArgumentError, ":#{arg} option required" if options[arg].nil? end disposition = options[:disposition].dup || ''attachment'' disposition <<= %(; filename="#{options[:filename]}") if options[:filename] headers.update( ''Content-Length'' => options[:length], ''Content-Type'' => options[:type].to_s.strip, # fixes a problem with extra ''\r'' with some browsers ''Content-Disposition'' => disposition, ''Content-Transfer-Encoding'' => ''binary'' ) headers.update(''Accept-Ranges'' => options[''Accept-Ranges'']) if options[''Accept-Ranges''] # Fix a problem with IE 6.0 on opening downloaded files: # If Cache-Control: no-cache is set (which Rails does by default), # IE removes the file it just downloaded from its cache immediately # after it displays the "open/save" dialog, which means that if you # hit "open" the file isn''t there anymore when the application that # is called for handling the download is run, so let''s workaround that headers[''Cache-Control''] = ''private'' if headers[''Cache- Control''] == ''no-cache'' end And I send my file like this: send_file path, :disposition => ''inline'', :type => m_type, ''Accept- Ranges'' => ''bytes'' On Nov 6, 11:50 pm, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I''m having trouble playing a video from my site on the iphone using > send_file. It seems that I''m missing the Accept-Ranges header in my > response. How can I set the Accept-Ranges header in my send_file > response?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
In retrospect this was dumb because mongrel doesn''t even support byte- range requests.... On Nov 7, 8:11 am, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> I actually was able to edit the source of rails to get this > implemented: > > vendor/rails/actionpack/lib/action_controller/streaming.rb > > def send_file_headers!(options) > options.update(DEFAULT_SEND_FILE_OPTIONS.merge(options)) > [:length, :type, :disposition].each do |arg| > raise ArgumentError, ":#{arg} option required" if > options[arg].nil? > end > > disposition = options[:disposition].dup || ''attachment'' > > disposition <<= %(; filename="#{options[:filename]}") if > options[:filename] > > headers.update( > ''Content-Length'' => options[:length], > ''Content-Type'' => options[:type].to_s.strip, # > fixes a problem with extra ''\r'' with some browsers > ''Content-Disposition'' => disposition, > ''Content-Transfer-Encoding'' => ''binary'' > ) > > headers.update(''Accept-Ranges'' => options[''Accept-Ranges'']) if > options[''Accept-Ranges''] > > # Fix a problem with IE 6.0 on opening downloaded files: > # If Cache-Control: no-cache is set (which Rails does by > default), > # IE removes the file it just downloaded from its cache > immediately > # after it displays the "open/save" dialog, which means that > if you > # hit "open" the file isn''t there anymore when the application > that > # is called for handling the download is run, so let''s > workaround that > headers[''Cache-Control''] = ''private'' if headers[''Cache- > Control''] == ''no-cache'' > end > > And I send my file like this: > > send_file path, :disposition => ''inline'', :type => m_type, ''Accept- > Ranges'' => ''bytes'' > > On Nov 6, 11:50 pm, eggie5 <egg...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > > I''m having trouble playing a video from my site on the iphone using > > send_file. It seems that I''m missing the Accept-Ranges header in my > > response. How can I set the Accept-Ranges header in my send_file > > response?--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---