We have our rails application running using lighttpd and everything seems fine with Firefox, but when the client is Explorer some media doesn''t get transferred from the server correctly. With Webrick, Content-Length is set when a request is made for an mp3 file. Using Firefox with lighttpd, Transfer-Encoding is set to chunked, so the Content-Length field isn''t required. With IE, however, neither Content-Length nor Transfer-Encoding is set. For straight-forward downloads that isn''t a problem (?), but I want the content to be played by a Flash mp3 player, and as it stands right now the player doesn''t seem to be receiving the mp3 -- and I''m pretty sure that''s because the response header is missing both Content-Length and Transfer-Encoding fields. There''s a very nice blog entry on this problem at: http://www.purpletech.com/blog/?itemid=43 , but adding the suggested after_filter to my application controller didn''t make a difference -- I assume either Rails or Lighttpd is over-riding my header settings. Does anybody have any clues as to how I can get the response header to include either Content-Length or Transfer-Encoding: chunked? Any advice greatly appreciated. Alexis -- Response headers are as follows: Firefox: HTTP/1.1 200 OK Date: Mon, 26 Jun 2006 09:23:59 GMT Server: lighttpd/1.4.10 Content-Type: audio/mpeg Set-Cookie: _session_id=640a71da388d5b1b9722cd8a4bb4da1b; path=/ Content-Transfer-Encoding: binary Cache-Control: private Content-Disposition: attachment; filename="testing.mp3" Connection: close Transfer-Encoding: chunked IE: HTTP/1.1 200 OK Date: Mon, 26 Jun 2006 09:23:31 GMT Server: lighttpd/1.4.10 Content-Type: audio/mpeg Set-Cookie: _session_id=12ac3d5b185fc60936d8d5e82459394a; path=/ Content-Transfer-Encoding: binary Cache-Control: private Content-Disposition: attachment; filename="testing.mp3" Connection: close -- Posted via http://www.ruby-forum.com/.
Alexis Glass
2006-Jun-27 02:27 UTC
[Rails] Re: Missing Content-Length header with lighttpd
So has nobody else had any problems with lighttpd and content-length headers not being set? Given that the lighttpd/fcgi combo seems to be the setup of choice, that would seem bizarre to me. The Rails wiki seems to recognize the problem -- from http://wiki.rubyonrails.org/rails/pages/HowtoUploadFiles>This stuff won?t work in lighttpd due to a bug in lighttpd and file uploads. >That was many versions ago, however. It may work now.Ignoring send_file or send_data and setting the headers/writing the body myself, I can seem to set just about every single header except Content-Length -- whatever I put in Content-Length gets completely ignored. The only way I can get anything put in Content-Length is actually if I set it (to anything) while simultaneously (and illegally) setting Transfer-Encoding to chunked. In this case, Content-Length is output as zero, which is useless anyway. Is it time to start looking into Mongrel? Alexis -- Posted via http://www.ruby-forum.com/.
On Tue, 2006-06-27 at 04:26 +0200, Alexis Glass wrote:> So has nobody else had any problems with lighttpd and content-length > headers not being set? Given that the lighttpd/fcgi combo seems to be > the setup of choice, that would seem bizarre to me. The Rails wiki > seems to recognize the problem -- from > http://wiki.rubyonrails.org/rails/pages/HowtoUploadFiles > > >This stuff won?t work in lighttpd due to a bug in lighttpd and file uploads. > >That was many versions ago, however. It may work now. > > Ignoring send_file or send_data and setting the headers/writing the body > myself, I can seem to set just about every single header except > Content-Length -- whatever I put in Content-Length gets completely > ignored. The only way I can get anything put in Content-Length is > actually if I set it (to anything) while simultaneously (and illegally) > setting Transfer-Encoding to chunked. In this case, Content-Length is > output as zero, which is useless anyway. > > Is it time to start looking into Mongrel?Try out the X-Sendfile header, it might work better if you just want rails to hand lighty a file. After that try using webrick and then mongrel directly and see if you can get the content-length. If you don''t then you''re doing it wrong. If you do then lighty is doing it wrong. -- Zed A. Shaw http://www.zedshaw.com/ http://mongrel.rubyforge.org/
Alexis Glass
2006-Jun-27 06:24 UTC
[Rails] Re: Re: Missing Content-Length header with lighttpd
Zed Shaw wrote:> Try out the X-Sendfile header, it might work better if you just want > rails to hand lighty a file. After that try using webrick and then > mongrel directly and see if you can get the content-length. If you > don''t then you''re doing it wrong. If you do then lighty is doing it > wrong.Thanks a lot for the suggestion. I can''t seem to get the x-sendfile header to do anything, but regardless even if I enter the path directly into the browser (which I assume using the x-sendfile header would be equivalent to) it seems that lighttpd is insisting on using a chunked transfer-encoding instead of setting the content-length (as I would like it to). I haven''t trie Mongrel yet, but Webrick seems perfectly happy to let me set the content length. I guess I''ll have to look into lighttpd''s documentation a bit more, but I suppose in the worst case scenario perhaps we could set apache up to serve the files (grumble). Thanks again for the help. Alexis -- Posted via http://www.ruby-forum.com/.
Alexis Glass
2006-Jun-27 09:38 UTC
[Rails] Re: Re: Missing Content-Length header with lighttpd
I guess I should have mentioned that lighttpd was behind apache 2.0.40 and being accessed by mod_proxy via ProxyPass. It looks like lighttpd isn''t doing anything wrong after all - but that mod_proxy is just stripping Content-Length from the headers. Will update to Apache 2.0.55 with fingers crossed. Alexis -- Posted via http://www.ruby-forum.com/.