summaryrefslogtreecommitdiff
path: root/rt/html/NoAuth/images/autohandler
blob: 720979830d5d7e4ad69fe2aff0be8c6952bf2bf7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<%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;
</%INIT>