($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";
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));
my ($uri,$localpart,$basepart,$dirname,$suffix,$flags,$key);
my (@itemz,@already_pushed_dir);
my (%objects,%dirs); # map uris to suffixes' flags
+ #my $debug=1; # for debug
print "FINDURIS, uritype: $uritype, uripattern: $uripattern, ".
- "format: $format\n\n";
+ "format: $format\n\n" if defined($debug);
if (($uritype eq "cic") or ($uritype eq "theory")) {
# get info only of one type: cic or theory
foreach (keys(%map)) { # select matching uris
$uri = $_;
- if ($uri =~ /^$uritype:$uripattern\//) {
- $localpart = $uri;
- $localpart =~ s/^$uritype:$uripattern\/(.*)/$1/;
+ if ($uri =~ /^$uritype:$uripattern(\/|$|\.)/) {
+ if ($uri =~ /^$uritype:$uripattern\//) { # directory match
+ $localpart = $uri;
+ $localpart =~ s/^$uritype:$uripattern\/(.*)/$1/;
+ } elsif ($uri =~ /^$uritype:$uripattern($|\.)/) { # file match
+ $localpart = $uri;
+ $localpart =~ s/^.*\/([^\/]*)/$1/;
+ } else {
+ die "Internal error, seems that requested match is none of ".
+ "directory match or file match";
+ }
+ print "LOCALPART: $localpart\n" if defined($debug);
if ($localpart =~ /^[^\/]*$/) { # no slash, an OBJECT
$basepart = $localpart;
- $basepart =~ s/^([^.]*\.[^.]*)(\.types)?(\.ann)?/$1/; # remove exts .types or
+ $basepart =~ s/^([^.]*\.[^.]*)(\.types)?(\.ann)?/$1/;
+ # remove exts .types or
# .types.ann
$flags = $objects{$basepart}; # get old flags
if ($localpart =~ /\.ann$/) {
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);
}
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 {
}
untie(%urls_of_uris);
- tie(%map, 'DB_File', $uris_dbm.".db", O_RDONLY, 0664);
+ tie(%map, 'DB_File', $uris_dbm.".db", O_RDWR, 0664);
}