[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cgiapp] How to download a dynamically generated file


Steve Hay <suppressed> wrote:
>
> I would rather do it in one step rather than two, and all inside
> CGI-Application, if possible.
>
> It seems a shame to have to step outside of CGI-Application to achieve
> something so simple.
>
> ... The -attachment parameter [...] would
> be annoying for PDF files which the browser normally "handles" by
> passing to the Adobe Reader.
>
> So I prefer not to use the -attachment argument in those headers.  The
> browser will still pop up a "Save As..." dialogue box anyway if it
> doesn't recognise the MIME type or has no action configured for it.
>
> ...you can print anything you like to the browser as long as (1)
you've
> set the correct Content-Type in the headers (using the -type argument)

right.  i've used that technique to return excel spreadsheets because i
didn't want to save temp files on the server, just feed them directly to
the browser.  in my case i found that returing a scalar (even a
multi-megabyte scalar!) worked perfectly fine for my application.  it
does seem a bit extreme, but this is not the type of thing one generally
needs to do for thousands of concurrent users, hundreds of times per
second :-)

in low volume situations (password protected "admin" interfaces, etc.)
it Just Works.  i've done it in cgi mode and mod_perl mode.  is this as
elegant as it could be?  i agree that it isn't.  and often i've wished
C:A would let me return a callback coderef instead of a scalar, that C:A
would just execute repeatedly, until it, say, returned undef.

perhaps jesse will consider such a patch... it certainly seems
reasonable to want C:A to accept a file handle as a return value.  in
fact i believe it was relatively recently that he added scalal refs as
allowable return values, in reponse to a few requests here on this
list...

-dave, putting in my vote for callback support too :-)




---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/suppressed/
              http://marc.theaimsgroup.com/?l=cgiapp&r=1&w=2
To unsubscribe, e-mail: suppressed
For additional commands, e-mail: suppressed


Mail converted by mhonarc 2.6.15
This archive provided courtesy of JSW4.NET, Internet Hosting Services for Small Business.