[Rt-commit] r4474 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Fri Feb 3 18:39:39 EST 2006


Author: ruz
Date: Fri Feb  3 18:39:38 2006
New Revision: 4474

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/NoAuth/images/autohandler

Log:
 r1654 at cubic-pc:  cubic | 2006-01-27 21:56:22 +0300
 * opened FILE, but reading from <file>, use $fh instead
 * turn on binmode on handle
 * flush buffers, otherwise we load all file into memmory
 


Modified: rt/branches/3.7-EXPERIMENTAL/html/NoAuth/images/autohandler
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/NoAuth/images/autohandler	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/NoAuth/images/autohandler	Fri Feb  3 18:39:38 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