- print "Help requested!";
- answer($c,"<html><body><h1>HTTP Getter Version ".
- $VERSION."</h1></body></html>","text/html","");
+ print "Help requested!\n";
+ html_nice_answer($c,"HTTP Getter Version: $VERSION");
+ } elsif ($http_method eq 'GET' and $http_path =~ /\.cgi$/) {
+ print "CGI requested!\n";
+ if ($http_path !~ /^\/[^\/]*\.cgi$/) {
+ html_nice_answer($c,"Invalid CGI name: $http_path, ".
+ "you can't request CGI that contain a slash in the name\n");
+ } elsif (stat "$cgi_dir"."$http_path") {
+ if (not -x "$cgi_dir/$http_path") {
+ html_nice_answer($c,"CGI $http_path found but not ".
+ "executable\n");
+ } else { # exec CGI and anser back its output
+ my %old_ENV = %ENV;
+ %ENV = ();
+ $ENV{'QUERY_STRING'} = $http_query;
+ my $cgi_output = `$cgi_dir/$http_path`;
+ answer($c,$cgi_output,"","");
+ %ENV = %old_ENV;
+ }
+ } else {
+ html_nice_answer($c,"CGI '$http_path' not found ".
+ "in CGI dir '$cgi_dir'");
+ }