I have an application which uses send_file to send a ZIP file to the client. This works nicely when it''s run on our development OS-X boxes, using mongrel from script/server, but on our production server, using mongrel behind Apache 2.2. with mod_proxy_balancer, the client gets 1 byte delivered :-( If I use wget -S to the URL in order to see the full headers I see this on production HTTP request sent, awaiting response... HTTP/1.1 500 Internal Server Error Date: Tue, 27 Feb 2007 08:52:54 GMT Server: Mongrel 1.0.1 Status: 500 Error Content-Transfer-Encoding: binary Cache-Control: private Content-Disposition: attachment; filename="somefile.zip" Content-Type: */* Content-Length: 1 Set-Cookie: _my_session_id=a65e09ab923208a4404893f2d3709196; path=/ Via: 1.0 www.myhost.com Connection: close 08:52:54 ERROR 500: Internal Server Error. whereas on the development servers I see HTTP request sent, awaiting response... HTTP/1.1 200 OK Connection: close Date: Tue, 27 Feb 2007 08:55:40 GMT Set-Cookie: _my_session_id=e8e877a3c0ae65386306e745df50b124; path=/ Status: 200 OK Content-Transfer-Encoding: binary Cache-Control: private Content-Disposition: attachment; filename="somefile.zip" Server: Mongrel 1.0.1 Content-Type: application/zip Content-Length: 3698448 Length: 3,698,448 (3.5M) [application/zip] I rather suspect that the problem may be related to the Content- Type: header which is correctly set on the development box, but yet is set to */* for some reason on production. The code which is called is this send_file @tour.zip_files, :filename => "# {@tour.filename}.zip", :type => ''application/zip'' where @tour.zip_files is a method which writes the ZIP file, and returns a path to it. This is working on the production box, insofar as it does write the ZIP files. A smaller problem, though it will be an issue in production, is that the filename saved was not the filename specified in the Content- Disposition but rather the filename in the URL which is something different. Kindest regards, Niall O Broin
Your production Mongrel is generating an error (500 Internal Server Error). Check your log/production.log where the error will be printed. Op 27-feb-2007, om 10:05 heeft Niall O Broin het volgende geschreven:> I have an application which uses send_file to send a ZIP file to the > client. This works nicely when it''s run on our development OS-X > boxes, using mongrel from script/server, but on our production > server, using mongrel behind Apache 2.2. with mod_proxy_balancer, the > client gets 1 byte delivered :-( > > If I use wget -S to the URL in order to see the full headers I see > this on production > > HTTP request sent, awaiting response... > HTTP/1.1 500 Internal Server Error > Date: Tue, 27 Feb 2007 08:52:54 GMT > Server: Mongrel 1.0.1 > Status: 500 Error > Content-Transfer-Encoding: binary > Cache-Control: private > Content-Disposition: attachment; filename="somefile.zip" > Content-Type: */* > Content-Length: 1 > Set-Cookie: _my_session_id=a65e09ab923208a4404893f2d3709196; path=/ > Via: 1.0 www.myhost.com > Connection: close > 08:52:54 ERROR 500: Internal Server Error. > > whereas on the development servers I see > > HTTP request sent, awaiting response... > HTTP/1.1 200 OK > Connection: close > Date: Tue, 27 Feb 2007 08:55:40 GMT > Set-Cookie: _my_session_id=e8e877a3c0ae65386306e745df50b124; path=/ > Status: 200 OK > Content-Transfer-Encoding: binary > Cache-Control: private > Content-Disposition: attachment; filename="somefile.zip" > Server: Mongrel 1.0.1 > Content-Type: application/zip > Content-Length: 3698448 > Length: 3,698,448 (3.5M) [application/zip] > > I rather suspect that the problem may be related to the Content- > Type: header which is correctly set on the development box, but yet > is set to */* for some reason on production. > > The code which is called is this > > send_file @tour.zip_files, :filename => "# > {@tour.filename}.zip", :type => ''application/zip'' > > where @tour.zip_files is a method which writes the ZIP file, and > returns a path to it. This is working on the production box, insofar > as it does write the ZIP files. > > A smaller problem, though it will be an issue in production, is that > the filename saved was not the filename specified in the Content- > Disposition but rather the filename in the URL which is something > different. > > > > Kindest regards, > > > > Niall O Broin > > > _______________________________________________ > Mongrel-users mailing list > Mongrel-users at rubyforge.org > http://rubyforge.org/mailman/listinfo/mongrel-users-- www.gomagazine.nl +31643904460 pobox 51059 nl-1007eb amsterdam -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 2423 bytes Desc: not available Url : http://rubyforge.org/pipermail/mongrel-users/attachments/20070227/3635a6d5/attachment.bin
On 2/27/07, Niall O Broin <niall at makalumedia.com> wrote:> > I have an application which uses send_file to send a ZIP file to the > client. This works nicely when it''s run on our development OS-X > boxes, using mongrel from script/server, but on our production > server, using mongrel behind Apache 2.2. with mod_proxy_balancer, the > client gets 1 byte delivered :-(Niall, what is the error logged when you get a 500 status in production? In any case, your best bet is to use the X-Sendfile header to tell Apache which file path to send. Streaming files from Rails means your Mongrel process is tied up for the duration -- no good. See http://wiki.rubyonrails.org/rails/pages/HowtoSendFilesFast for more on how to use Apache''s mod_xsendfile. Best, jeremy -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/mongrel-users/attachments/20070227/9185da37/attachment-0001.html