[Mongrel] send_file and ZIP files

Niall O Broin niall at makalumedia.com
Tue Feb 27 04:05:49 EST 2007


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




More information about the Mongrel-users mailing list