print "\nRequest: ".$r->url."\n\n";
my $http_method = $r->method;
my $http_path = $r->url->path;
+ my $http_query = $r->url->query;
if ($http_method eq 'GET' and $http_path eq "/getciconly") {
# finds the uri, url and filename
$cont = "<?xml version=\"1.0\"?><html_link>$quoted_html_link</html_link>";
answer($c,$cont);
} elsif ($http_method eq 'GET' and $http_path eq "/update") {
+ # rebuild urls_of_uris.db
print "Update requested...\n";
mk_urls_of_uris();
kill(USR1,getppid()); # signal changes to parent
print " done\n";
answer($c,"<html><body><h1>Update done</h1></body></html>");
- } elsif ($http_method eq 'GET' and $http_path eq "/version") {
- print "Version requested!";
- answer($c,"<html><body><h1>HTTP Getter Version ".$VERSION."</h1></body></html>");
+ } elsif ($http_method eq 'GET' and $http_path eq "/ls") {
+ # send back keys that begin with a given uri
+ my $baseuri = $http_query;
+ $baseuri =~ s/^.*baseuri=(.*)&.*$/$1/;
+ chop $baseuri if ($baseuri =~ /.*\/$/); # remove trailing "/"
+ my $outype = $http_query; # output type, might be 'txt' or 'xml'
+ $outype =~ s/^.*&type=(.*)$/$1/;
+ if (($outype ne 'txt') and ($outype ne 'xml')) { # invalid out type
+ print "Invalid output type specified: $outype\n";
+ answer($c,"<html><body><h1>Invalid output type, may be ".
+ "\"txt\" or \"xml\"</h1></body></html>");
+ } else { # valid output type
+ print "BASEURI $baseuri, TYPE $outype\n";
+ my $key;
+ $cont = "";
+ $cont .= "<urilist>\n" if ($outype eq "xml");
+ foreach (keys(%map)) { # search for uri that begin with $baseuri
+ if ($_ =~ /^$baseuri\//) {
+ $cont .= "<uri>" if ($outype eq "xml");
+ $cont .= $_;
+ $cont .= "\n" if ($outype eq "txt");
+ $cont .= "</uri>\n" if ($outype eq "xml");
+ }
+ }
+ $cont .= "</urilist>" if ($outype eq "xml");
+ answer($c,$cont);
+ }
+ } elsif ($http_method eq 'GET' and $http_path eq "/version") {
+ print "Version requested!";
+ answer($c,"<html><body><h1>HTTP Getter Version ".
+ $VERSION."</h1></body></html>");
} else {
- print "\nINVALID REQUEST!!!!!\n";
+ print "\n";
+ print "INVALID REQUEST!!!!!\n";
+ print "(PATH: ",$http_path,", ";
+ print "QUERY: ",$http_query,")\n";
$c->send_error(RC_FORBIDDEN)
}
print "\nRequest solved: ".$r->url."\n\n";