[Rt-commit] r4499 - rt/branches/3.5-TESTING/html/NoAuth/images
ruz at bestpractical.com
ruz at bestpractical.com
Mon Feb 6 14:35:38 EST 2006
Author: ruz
Date: Mon Feb 6 14:35:37 2006
New Revision: 4499
Modified:
rt/branches/3.5-TESTING/html/NoAuth/images/autohandler
Log:
* opened FILE, but reading from <file>, use $fh instead
** result off tidy script
* turn on binmode on handle
* flush buffers, otherwise we load all file into memmory
Modified: rt/branches/3.5-TESTING/html/NoAuth/images/autohandler
==============================================================================
--- rt/branches/3.5-TESTING/html/NoAuth/images/autohandler (original)
+++ rt/branches/3.5-TESTING/html/NoAuth/images/autohandler Mon Feb 6 14:35:37 2006
@@ -1,24 +1,27 @@
-<%init>
+<%INIT>
# This autohandler will spit out RT's images if the user hasn't
# properly configured their webserver to stop RT from passing
# images through the mason handler.
my $file = $m->base_comp->source_file;
-my $type = "application/octet-stream";
+my $type = "application/octet-stream";
if ($file =~ /\.(gif|png|jpe?g)$/i) {
$type = "image/$1";
$type =~ s/jpg/jpeg/gi;
}
-die unless (-f $file && -r $file);
+die "file not found" unless -f $file && -r _;
+
$r->content_type($type);
-open (FILE, "<$file") || die;
+open my $fh, "<$file" or die "couldn't open file: $!";
+binmode($fh);
{
local $/ = \16384;
- $m->out($_) while (<file>);
- close(FILE);
+ $m->out($_) while (<$fh>);
+ $m->flush_buffer;
}
+close $fh;
$m->abort;
-</%init>
+</%INIT>
More information about the Rt-commit
mailing list