From: Claudio Sacerdoti Coen Date: Fri, 1 Dec 2000 19:59:41 +0000 (+0000) Subject: update method added; now returns NOT_FOUND if the document is not found X-Git-Tag: nogzip~115 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=e4923cacaf9d64f3d69afd79b85a21660dc0ab76;p=helm.git update method added; now returns NOT_FOUND if the document is not found --- diff --git a/helm/http_getter/http_getter.pl b/helm/http_getter/http_getter.pl index ccc8a82b8..769a47cc3 100755 --- a/helm/http_getter/http_getter.pl +++ b/helm/http_getter/http_getter.pl @@ -27,6 +27,7 @@ print "helm_dir: $helm_dir\n"; print "dtd_dir: $dtd_dir\n"; print "urls_of_uris.db: $uris_dbm.db\n"; $SIG{CHLD} = "IGNORE"; # do not accumulate defunct processes +$SIG{USR1} = \&update; # sent by the child to make the parent update while (my $c = $d->accept) { if (fork() == 0) { while (my $r = $c->get_request) { @@ -48,14 +49,18 @@ while (my $c = $d->accept) { $cicfilename = $helm_dir.$cicfilename.".xml"; my $cicurl = $map{$cicuri}; + if (!defined($cicurl)) { + print "\nNOT FOUND!!!!!\n"; + $c->send_error(RC_NOT_FOUND) + } else { + print_request("cic",$cicuri,$cicurl,$cicfilename); - print_request("cic",$cicuri,$cicurl,$cicfilename); - - # Retrieves the file - my $ciccontent = download(0,"cic",$cicurl,$cicfilename); + # Retrieves the file + my $ciccontent = download(0,"cic",$cicurl,$cicfilename); - # Answering the client - answer($c,$ciccontent); + # Answering the client + answer($c,$ciccontent); + } } elsif ($http_method eq 'GET' and $http_path eq "/get") { # finds the uris, urls and filenames my $cicuri = $inputuri, @@ -91,23 +96,30 @@ while (my $c = $d->accept) { my $typesurl = $map{$typesuri} if $typesuri; my $annurl = $map{$annuri} if $annuri; - print_request("cic",$cicuri,$cicurl,$cicfilename); - print_request("types",$typesuri,$typesurl,$typesfilename) - if ($typesuri); - print_request("ann",$annuri,$annurl,$annfilename) - if ($annuri); - - # Retrieves the files - - my $ciccontent = download(1,"cic",$cicurl,$cicfilename); - my $typescontent = - download(1,"types",$typesurl,$typesfilename) if ($typesuri); - my $anncontent = - download(1,"ann",$annurl,$annfilename) if ($annuri); - - # Merging the files together - - my $merged = <send_error(RC_NOT_FOUND) + } else { + print_request("cic",$cicuri,$cicurl,$cicfilename); + print_request("types",$typesuri,$typesurl,$typesfilename) + if ($typesuri); + print_request("ann",$annuri,$annurl,$annfilename) + if ($annuri); + + # Retrieves the files + + my $ciccontent = download(1,"cic",$cicurl,$cicfilename); + my $typescontent = + download(1,"types",$typesurl,$typesfilename) if ($typesuri); + my $anncontent = + download(1,"ann",$annurl,$annfilename) if ($annuri); + + # Merging the files together + + my $merged = < $ciccontent @@ -116,8 +128,9 @@ $anncontent EOT - # Answering the client - answer($c,$merged); + # Answering the client + answer($c,$merged); + } } elsif ($http_method eq 'GET' and $http_path eq "/getdtd") { my $filename = $inputuri; $filename = $dtd_dir."/".$filename; @@ -142,6 +155,12 @@ EOT print "\nConfiguration requested, returned #$quoted_html_link#\n"; $cont = "$quoted_html_link"; answer($c,$cont); + } elsif ($http_method eq 'GET' and $http_path eq "/update") { + print "Update requested..."; + update(); + kill(USR1,getppid()); + print " done\n"; + answer($c,"

Update done

"); } else { print "\nINVALID REQUEST!!!!!\n"; $c->send_error(RC_FORBIDDEN) @@ -221,3 +240,8 @@ sub answer $res->content($cont); $c->send_response($res); } + +sub update { + untie %map; + tie(%map, 'DB_File', $uris_dbm.".db", O_RDONLY, 0664); +}