handle erros
This commit is contained in:
parent
d54340e067
commit
f17e930ab4
|
@ -0,0 +1,2 @@
|
||||||
|
<h1>Error <% err %></h1>
|
||||||
|
If you think this is a bug, please email albino AT autistici DOT org. Thanks!
|
|
@ -30,18 +30,25 @@ my $request = FCGI::Request(
|
||||||
);
|
);
|
||||||
|
|
||||||
while ($request->Accept() <= 0) {
|
while ($request->Accept() <= 0) {
|
||||||
print "Content-Type: text/html\n\n";
|
|
||||||
my $content;
|
my $content;
|
||||||
|
my $code;
|
||||||
|
|
||||||
switch ($ENV{"REQUEST_URI"}) {
|
switch ($ENV{"REQUEST_URI"}) {
|
||||||
case "/debug" {
|
case "/debug" {
|
||||||
# TODO - remove this, it's a security vulnerability
|
# TODO - remove this, it's a security vulnerability
|
||||||
use Data::Dumper;
|
use Data::Dumper;
|
||||||
$content = "<textarea>" . Dumper(\%ENV) . "</textarea>";
|
$content = "<textarea>" . Dumper(\%ENV) . "</textarea>";
|
||||||
|
$code = "\n"; # 200 OK
|
||||||
}
|
}
|
||||||
case "/" {
|
case "/" {
|
||||||
my $tt = read_file("$Bin/index.tt");
|
my $tt = read_file("$Bin/index.tt");
|
||||||
$content = ${ $tmpl->render($tt, {version => $VERSION}) };
|
$content = ${ $tmpl->render($tt, {version => $VERSION}) };
|
||||||
|
$code = "\n"; # 200 OK
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
my $tt = read_file("$Bin/error.tt");
|
||||||
|
$content = ${ $tmpl->render($tt, {err => 404}) };
|
||||||
|
$code = "Status: 404 Not Found\n\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,5 +59,5 @@ while ($request->Accept() <= 0) {
|
||||||
content => $content,
|
content => $content,
|
||||||
},
|
},
|
||||||
);
|
);
|
||||||
print ${$html};
|
print "Content-Type: text/html\n", $code, ${$html};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue