From f17e930ab45bf0af58dce07e010bb18a2dd03822 Mon Sep 17 00:00:00 2001 From: Al Beano Date: Thu, 25 Aug 2016 17:31:32 +0100 Subject: [PATCH] handle erros --- tormon/error.tt | 2 ++ tormon/tormon.fcgi | 11 +++++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) create mode 100644 tormon/error.tt diff --git a/tormon/error.tt b/tormon/error.tt new file mode 100644 index 0000000..aaec234 --- /dev/null +++ b/tormon/error.tt @@ -0,0 +1,2 @@ +

Error <% err %>

+If you think this is a bug, please email albino AT autistici DOT org. Thanks! diff --git a/tormon/tormon.fcgi b/tormon/tormon.fcgi index f9f07b4..91ad1f7 100755 --- a/tormon/tormon.fcgi +++ b/tormon/tormon.fcgi @@ -30,18 +30,25 @@ my $request = FCGI::Request( ); while ($request->Accept() <= 0) { - print "Content-Type: text/html\n\n"; my $content; + my $code; switch ($ENV{"REQUEST_URI"}) { case "/debug" { # TODO - remove this, it's a security vulnerability use Data::Dumper; $content = ""; + $code = "\n"; # 200 OK } case "/" { my $tt = read_file("$Bin/index.tt"); $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, }, ); - print ${$html}; + print "Content-Type: text/html\n", $code, ${$html}; }