+sub fail_open_file
+{
+ (my $method, my $type, my $path) = @_;
+
+ return failpage(
+ "Status: 404 Not Found\n",
+ "404 Not Found",
+ "Can't open ".
+ ($type ne '' ? $type : 'file').
+ ($path ne '' ? ': "'.$path.'"' : '').
+ '.',
+ $method
+ );
+}
+
+sub fail_500
+{
+ (my $method, my $text) = @_;
+ return failpage(
+ "Status: 500 Internal Server Error\n",
+ "500 Internal Server Error",
+ $text,
+ $method
+ );
+}
+
+sub redirect
+{
+ (my $method, my $uri, my $code) = @_;
+ my $status;
+ if ($code eq '') {
+ $code = 302
+ }
+ $code = int($code);
+ if ($code == 301) {
+ $status = '301 Moved Permanently';
+ }
+ elsif ($code == 302) {
+ $status = '302 Found';
+ }
+ elsif ($code == 303) {
+ $status = '303 See Other';
+ }
+ elsif ($code == 307) {
+ $status = '307 Temporary Redirect';
+ }
+ elsif ($code == 308) {
+ $status = '308 Permanent Redirect';
+ }
+ else{
+ $status = "$code Redirect";
+ }
+ return failpage(
+ "Status: $status\nLocation: $uri\n",
+ $status,
+ '',
+ $method,
+ $uri
+ );
+}
+