[Rt-commit] r17437 - in rt/3.8/trunk: . share/html/NoAuth/images

falcone at bestpractical.com falcone at bestpractical.com
Tue Dec 30 13:24:49 EST 2008


Author: falcone
Date: Tue Dec 30 13:24:48 2008
New Revision: 17437

Modified:
   rt/3.8/trunk/   (props changed)
   rt/3.8/trunk/share/html/NoAuth/css/autohandler
   rt/3.8/trunk/share/html/NoAuth/images/autohandler

Log:
 r42943 at ketch:  falcone | 2008-12-30 13:16:40 -0500
 * refactor the file opening/printing code off to SendStaticFile


Modified: rt/3.8/trunk/share/html/NoAuth/css/autohandler
==============================================================================
--- rt/3.8/trunk/share/html/NoAuth/css/autohandler	(original)
+++ rt/3.8/trunk/share/html/NoAuth/css/autohandler	Tue Dec 30 13:24:48 2008
@@ -46,32 +46,14 @@
 %# 
 %# END BPS TAGGED BLOCK }}}
 <%init>
-RT::Interface::Web::StaticFileHeaders();
-my $type;
 my $file = $m->base_comp->source_file;
 
 if ($file =~ /\.(gif|png|jpe?g)$/i) {
-    $type = "image/$1";
-    $type =~ s/jpg/jpeg/gi;
-
-
-die "file $file not found" unless -f $file && -r _;
-
-$r->content_type($type);
-open my $fh, "<$file" or die "couldn't open file: $!";
-binmode($fh);
-{
-    local $/ = \16384;
-    $m->out($_) while (<$fh>);
-    $m->flush_buffer;
-}
-close $fh;
-$m->abort;
+    $m->comp( '/Elements/SendStaticFile', File => $file );
 } else {
-
-$r->content_type('text/css') ;
-$m->call_next();
-return();
+    RT::Interface::Web::StaticFileHeaders();
+    $r->content_type('text/css') ;
+    $m->call_next();
+    return();
 }
-
 </%init>

Modified: rt/3.8/trunk/share/html/NoAuth/images/autohandler
==============================================================================
--- rt/3.8/trunk/share/html/NoAuth/images/autohandler	(original)
+++ rt/3.8/trunk/share/html/NoAuth/images/autohandler	Tue Dec 30 13:24:48 2008
@@ -1,28 +1,8 @@
 <%INIT>
-&RT::Interface::Web::StaticFileHeaders();
-
 # 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";
-if ($file =~ /\.(gif|png|jpe?g)$/i) {
-    $type = "image/$1";
-    $type =~ s/jpg/jpeg/gi;
-}
-
-die "file not found" unless -f $file && -r _;
-
-$r->content_type($type);
-open my $fh, "<$file" or die "couldn't open file: $!";
-binmode($fh);
-{
-    local $/ = \16384;
-    $m->out($_) while (<$fh>);
-    $m->flush_buffer;
-}
-close $fh;
-$m->abort;
+$m->comp( '/Elements/SendStaticFile', File => $file );
 </%INIT>


More information about the Rt-commit mailing list