import rt 3.8.8
[freeside.git] / rt / html / NoAuth / images / autohandler
1 <%INIT>
2 &RT::Interface::Web::StaticFileHeaders();
3
4 # This autohandler will spit out RT's images if the user hasn't 
5 # properly configured their webserver to stop RT from passing 
6 # images through the mason handler.
7 my $file = $m->base_comp->source_file;
8
9
10 my $type = "application/octet-stream";
11 if ($file =~ /\.(gif|png|jpe?g)$/i) {
12     $type = "image/$1";
13     $type =~ s/jpg/jpeg/gi;
14 }
15
16 die "file not found" unless -f $file && -r _;
17
18 $r->content_type($type);
19 open my $fh, "<$file" or die "couldn't open file: $!";
20 binmode($fh);
21 {
22     local $/ = \16384;
23     $m->out($_) while (<$fh>);
24     $m->flush_buffer;
25 }
26 close $fh;
27 $m->abort;
28 </%INIT>