Hi, >From an Embperl perspective this doesn't makes a difference. So use what better works for you. I agree that the first one is easier to read and has less problems with withspaces.
Gerald > -----Original Message----- > From: Gunnar Wolf [mailto:[EMAIL PROTECTED] > Sent: Wednesday, August 09, 2006 7:03 PM > To: Gerald Richter > Cc: 'Frank Wesemann'; embperl@perl.apache.org > Subject: Re: Delivering binary content from a Embperl application > > Gerald Richter dijo [Mon, Aug 07, 2006 at 03:59:30PM +0200]: > > This might work with Apache 1.3 by chance, but it will not > with Apache > > 2.0, because $image->write('-') writes to STDOUT which is > never send > > to the client, at least not by default. > > > > The best would be to do something like > > > > $imgdata = $image -> <get_image> () ; # I don't know the correct > > ImageMagik function to use, # but it should return the > image data # -> > > no exit here -][+ $imgdata +] > > > > # Make sure you have no extra spaces here or newlines in > your source. > > Hmh... I followed Torsten's advice, and did this: > > ---------------------------------------------------------------------- > [- > # Omitting some irrelevant bits regarding my app's logic > $file = Comas::File->new(-db => $epreq->{db}, -id => $fdat{file_id}); > > if (defined($file) and $file->get_proposal_id == > $fdat{proposal_id}) { > my $filename = $file->get_filename; > > my $mime = MIME::Types->new or die "Could not query MIME type"; > $http_headers_out{'Content-Type'} = $mime->mimeTypeOf($filename) > or 'application/octet-stream'; > > $http_headers_out{'Content-Disposition'} = "attachment; > filename=". > $filename; > print OUT $file->get_data; > > # Exit in order not to break binary content (don't > worry, this is > # Embperl-safe) > exit 0; > } > -] > Could not open requested file > ---------------------------------------------------------------------- > > Note that I'm using Apache 2.0, and it works correctly. I > like keeping this all inside a single block, but... Would you > recommend something like this instead? > > ---------------------------------------------------------------------- > [- $file = Comas::File->new(-db => $epreq->{db}, -id => > $fdat{file_id}); -] [$ if (defined($file) and > $file->get_proposal_id == $fdat{proposal_id}) $] > [- (... Rest of logic ...) > $file_data = $file->get_data -] > [+ $file_data +] > [$ else $] > Could not open requested file > [$ endif $] > ---------------------------------------------------------------------- > > IMHO, the first way is much clearer, and less prone for some > whitespace or wrongly appended thing end up modifying the sent binary. > > Greetings, > > -- > Gunnar Wolf - [EMAIL PROTECTED] - (+52-55)5623-0154 / 1451-2244 > PGP key 1024D/8BB527AF 2001-10-23 > Fingerprint: 0C79 D2D1 2C4E 9CE4 5973 F800 D80E F35A 8BB5 27AF > > > ** Virus checked by BB-5000 Mailfilter ** > !DSPAM:44da2bc0115051971813638! > --------------------------------------------------------------------------- Gerald Richter ecos electronic communication services gmbh IT-Securitylösungen * Webapplikationen mit Apache/Perl/mod_perl/Embperl Post: Tulpenstrasse 5 D-55276 Dienheim b. Mainz E-Mail: [EMAIL PROTECTED] Voice: +49 6133 939-122 WWW: http://www.ecos.de/ Fax: +49 6133 939-333 --------------------------------------------------------------------------- ECOS BB-5000 Firewall- und IT-Security Appliance: www.bb-5000.info --------------------------------------------------------------------------- ** Virus checked by BB-5000 Mailfilter ** --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]