perl-embperl mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Torsten Luettgert <>
Subject Re: Delivering binary content from a Embperl application
Date Fri, 04 Aug 2006 10:11:03 GMT
On Wed, 2006-08-02 at 12:50 -0500, Gunnar Wolf wrote:
> Ok, here goes the question: My applications have to deliver binary
> content stored in a database or generated on the fly. How can I do
> this from within my Embperl structure (I'm using the Embperl object
> application), without having to delegate this to a traditional CGI or
> something like that?

Don't know about Embperl object, but for me, it "just works".
Here is some (reduced) code I use for delivering jpeg images:

   # some permission checking and obtaining $imgpath omitted
   if( -f $imgpath && $permission ) {
      $http_headers_out{'Content-Length'} = -s $imgpath;
      $http_headers_out{'Content-Type'} = 'image/jpeg';
      $http_headers_out{'Cache-Control'} = 'no-cache';
      $http_headers_out{'Pragma'} = 'no-cache';
      $http_headers_out{'Expires'} = '0';
      open(I, '<:raw', $imgpath);
      undef $/;
      print OUT <I>;
      $/ = "\n";
      exit 0;
(display error message)

What's important is that there's no white space or anything else before
the first [- or you'll have that at the top of the output.


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message