From: Stefano Zacchiroli Date: Sat, 17 Feb 2001 23:02:10 +0000 (+0000) Subject: Added 'ls' method: return a list of uri that begin with a given uri. X-Git-Tag: v0_1_2~109 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=10c1185793af5ae402e7a4dbe016b72f5bb6c727;p=helm.git Added 'ls' method: return a list of uri that begin with a given uri. Response may be in CR-separated line or in a simple XML document. --- diff --git a/helm/http_getter/http_getter.pl.in b/helm/http_getter/http_getter.pl.in index 22fad1a3e..e6dde7f6e 100755 --- a/helm/http_getter/http_getter.pl.in +++ b/helm/http_getter/http_getter.pl.in @@ -94,6 +94,7 @@ while (my $c = $d->accept) { 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 @@ -290,16 +291,48 @@ EOT $cont = "$quoted_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,"

Update done

"); - } elsif ($http_method eq 'GET' and $http_path eq "/version") { - print "Version requested!"; - answer($c,"

HTTP Getter Version ".$VERSION."

"); + } 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,"

Invalid output type, may be ". + "\"txt\" or \"xml\"

"); + } else { # valid output type + print "BASEURI $baseuri, TYPE $outype\n"; + my $key; + $cont = ""; + $cont .= "\n" if ($outype eq "xml"); + foreach (keys(%map)) { # search for uri that begin with $baseuri + if ($_ =~ /^$baseuri\//) { + $cont .= "" if ($outype eq "xml"); + $cont .= $_; + $cont .= "\n" if ($outype eq "txt"); + $cont .= "\n" if ($outype eq "xml"); + } + } + $cont .= "" if ($outype eq "xml"); + answer($c,$cont); + } + } elsif ($http_method eq 'GET' and $http_path eq "/version") { + print "Version requested!"; + answer($c,"

HTTP Getter Version ". + $VERSION."

"); } 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";