]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/http_getter/http_getter.pl.in
minidom.c : fixed memory leak
[helm.git] / helm / http_getter / http_getter.pl.in
index 924ddbb1930e966ef1c810e5f1633d597e31ca44..e06a3a5e2fbd43e6d3f8cc93bfed0131164d3062 100755 (executable)
@@ -83,7 +83,7 @@ $myownurl  =~ s/http:\/\/(.*):(.*)/$1/;
 ($myownurl) = gethostbyname($myownurl);
 $myownurl = "http://".$myownurl.":".$myownport;
 
-tie(%map, 'DB_File', $uris_dbm.".db", O_RDONLY, 0664);
+tie(%map, 'DB_File', $uris_dbm.".db", O_RDWR, 0664);
 print "Please contact me at: <URL:", $myownurl."/", ">\n";
 print "helm_dir: $helm_dir\n";
 print "style_dir: $style_dir\n";
@@ -153,8 +153,30 @@ while (my $c = $d->accept) {
                my $ciccontent = download($patch_dtd,"cic",$cicurl,$cicfilename,$answerformat);
 
                # Answering the client
+              if ($answerformat eq "normal") {
+                answer($c,$ciccontent,"text/xml","");
+               } else {
                 answer($c,$ciccontent,"text/xml","x-gzip");
+               }
             }
+        } elsif ($http_method eq 'GET' and $http_path eq "/register") {
+          my $inputurl = $cgi->param('url');
+          print "Register requested...\n";
+          $map{$inputuri}=$inputurl;
+
+          # Now let's clean the cache
+          my $cicfilename = $inputuri;
+          $cicfilename =~ s/cic:(.*)/$1/;
+          $cicfilename =~ s/theory:(.*)/$1/;
+
+          print "Unlinking ".$helm_dir.$cicfilename.".xml[.gz]\n";
+          unlink ($helm_dir.$cicfilename.".xml");
+          unlink ($helm_dir.$cicfilename.".xml.gz");
+
+          kill(USR1,getppid()); # signal changes to parent
+          untie %map;
+          print "done\n";
+          html_nice_answer($c,"Register done");
         } elsif ($http_method eq 'GET' and $http_path eq "/resolve") {
           my $outputurl = $map{$inputuri};
           $outputurl = "" if (not defined($outputurl));
@@ -603,6 +625,9 @@ sub answer {
    unless ($contype eq "");
  $res->push_header("Content-Encoding" => $contenc)
    unless ($contenc eq "");
+ $res->push_header("Cache-Control" => "no-cache");
+ $res->push_header("Pragma" => "no-cache");
+ $res->push_header("Expires" => "0");
  $c->send_response($res);
 }
 
@@ -630,7 +655,7 @@ sub helm_wget {
 
 sub update {
  untie %map;
- tie(%map, 'DB_File', $uris_dbm.".db", O_RDONLY, 0664);
+ tie(%map, 'DB_File', $uris_dbm.".db", O_RDWR, 0664);
 }
 
 sub mk_urls_of_uris {
@@ -678,6 +703,6 @@ sub mk_urls_of_uris {
  }
 
  untie(%urls_of_uris);
- tie(%map, 'DB_File', $uris_dbm.".db", O_RDONLY, 0664);
+ tie(%map, 'DB_File', $uris_dbm.".db", O_RDWR, 0664);
 }