streaming dynamic downloads?

jeff emminger jemminger at gmail.com
Sun May 18 07:34:17 MSD 2008


[SOLVED]

On Sat, May 17, 2008 at 10:23 PM, jeff emminger <jemminger at gmail.com> wrote:
> I have a php app running through fastcgi, and there's a page where I
> stream out a file for the user to download:
>
>        $output = dynamically_generated_content();
>        header("Content-type: application/octet-stream");
>        header("Content-disposition: attachment; filename=somefile.xml");
>        echo $output;
>
> This works fine in apache, but in nginx all I get is a zero-size file
> called 'somefile' (no extension)
>
> Is there a way to make this work?  The file is generated on the fly.
>
> Thanks,
> Jeff
>

Turned out to be a problem with the URL I was using.  I was pointing
to "/export?xml" (no trailing slash), and Nginx was redirecting to
"/export/" (with trailing slash) but dropping the querystring.  I
changed my link to point to "/export/?xml" and all is well.  The
zero-kb file download was a result of my script expecting the file
format in the querystring, and not finding the format it generated
nothing and sent back the empty file.





More information about the nginx mailing list