[Mongrel] x_send_file sends a 1 byte file

Kirk Haines wyhaines at gmail.com
Tue Jun 17 12:32:39 EDT 2008

On Tue, Jun 17, 2008 at 1:23 AM, Jeremy Kemper <jeremy at bitsweat.net> wrote:
> On Mon, Jun 16, 2008 at 11:35 PM, George Schreiber <lists at ruby-forum.com> wrote:
>> Hello,
>> sorry if creating a dupe...
>> I'm trying to download files to authenticated users in my app. I've set
>> up x_send_file. All seems to be correct to me, however when I try to
>> download any file, I get a 1-byte long file downloaded.
> This only works with a frontend httpd to intercept the X-Sendfile
> response header and send the actual file.
> Without a frontend httpd, you're seeing the expected result. Use
> firebug to verify.

To expand on what Jeremy said, x_send_file just sets an HTTP header,
X-Sendfile, in the response.

It's up to whatever is running in front of your processes to see that
header and then to do something with it.

So, in order to adequately test it, you will have to have _something_
in front of your processes which handle it.  Also be aware that only
some web servers implement X-Sendfile (Apache, via mod_xsendfile,
lighttpd natively [it originated with them], and Swiftiply are the
three that come to mind).  Litespeed has their own redirect syntax
(which they spin to make it sound better than the others).  Nginx also
has it's own approach with x-accel-redirect (which Swiftiply may
support in the future, as well).

So if you are using any one of those mechanisms for delivering static
file downloads, to test it you will have to have a compatible front
end running, and without some (fairly minor) code changes, you are
locked into whatever one you choose to use.

Hope this helps.

Kirk Haines

More information about the Mongrel-users mailing list