sub quitcgi {
- my $msg = shift;
+ my ($msg, $status) = @_;
+ $status //= '500 Internal Server Error';
+ print "Status: $status\n";
print "Content-Type: text/html\n\n";
print fill_in_template(template=>'cgi/quit',
variables => {msg => $msg}
);
# This is craptacular.
-my $ref = $param{bug} or quitcgi("No bug number");
-$ref =~ /(\d+)/ or quitcgi("Invalid bug number");
+my $ref = $param{bug} or quitcgi("No bug number", '400 Bad Request');
+$ref =~ /(\d+)/ or quitcgi("Invalid bug number", '400 Bad Request');
$ref = $1;
my $short = "#$ref";
my ($msg) = $param{msg} =~ /^(\d+)$/ if exists $param{msg};
my $indexon = $param{indexon};
if ($param{indexon} !~ m/^(pkg|src|maint|submitter|tag)$/) {
- quitcgi("You have to choose something to index on");
+ quitcgi("You have to choose something to index on", '400 Bad Request');
}
my $repeatmerged = $param{repeatmerged} eq 'yes';
my $archive = $param{archive} eq "yes";
my $sortby = $param{sortby};
if ($sortby !~ m/^(alpha|count)$/) {
- quitcgi("Don't know how to sort like that");
+ quitcgi("Don't know how to sort like that", '400 Bad Request');
}
my $Archived = $archive ? " Archived" : "";
}
}
-quitcgi("You have to choose something to select by") unless grep {exists $param{$_}} keys %package_search_keys;
+quitcgi("You have to choose something to select by", '400 Bad Request')
+ unless grep {exists $param{$_}} keys %package_search_keys;
my $Archived = $param{archive} ? " Archived" : "";
use strict;
use CGI qw(param remote_host);
-sub quitcgi($) {
- my $msg = shift;
+sub quitcgi($;$) {
+ my ($msg, $status) = @_;
+ $status //= '500 Internal Server Error';
+ print "Status: $status\n";
print "Content-Type: text/html\n\n";
print "<HTML><HEAD><TITLE>Error</TITLE></HEAD><BODY>\n";
print "An error occurred. Dammit.\n";
exit 0;
}
-my $bug = param('bug') or quitcgi('No bug specfied');
-quitcgi('No valid bug number') unless $bug =~ /^\d{3,6}$/;
+my $bug = param('bug') or quitcgi('No bug specfied', '400 Bad Request');
+quitcgi('No valid bug number', '400 Bad Request') unless $bug =~ /^\d{3,6}$/;
my $remote_host = remote_host or quitcgi("No remote host");
my $ok = param('ok');
if (not defined $ok) {