X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=helm%2Fhttp_getter%2Fhttp_getter.pl.in;h=89f496ac7bc201e6cadc50bb09812b347eace3cb;hb=083c36a4acd76127530b9af3d4c6c311f447d79b;hp=b1ec80aeb972c3a0dc7941f8da67a2b0574deb68;hpb=38034d883494780a817bb2d8cc30ac9b7d00b974;p=helm.git diff --git a/helm/http_getter/http_getter.pl.in b/helm/http_getter/http_getter.pl.in index b1ec80aeb..89f496ac7 100755 --- a/helm/http_getter/http_getter.pl.in +++ b/helm/http_getter/http_getter.pl.in @@ -23,6 +23,8 @@ # For details, see the HELM World-Wide-Web page, # http://cs.unibo.it/helm/. +my $VERSION = "@VERSION@"; + # First of all, let's load HELM configuration use Env; my $HELM_LIB_DIR = $ENV{"HELM_LIB_DIR"}; @@ -35,7 +37,7 @@ if (defined ($HELM_LIB_DIR)) { } # Let's override the configuration file -$styles_dir = $ENV{"HELM_STYLE_DIR"} if (defined ($ENV{"HELM_STYLE_DIR"})); +$style_dir = $ENV{"HELM_STYLE_DIR"} if (defined ($ENV{"HELM_STYLE_DIR"})); $dtd_dir = $ENV{"HELM_DTD_DIR"} if (defined ($ENV{"HELM_DTD_DIR"})); # : TODO temporary, move this setting to configuration file @@ -62,9 +64,20 @@ use Compress::Zlib; #CSC: altra roba da sistemare segnata con CSC my $d = new HTTP::Daemon LocalPort => 8081; +my $myownurl = $d->url; + +# Let's patch the returned URL +$myownurl =~ s/\/$//; # chop the final slash +my $myownport = $myownurl; +$myownport =~ s/http:\/\/(.*):(.*)/$2/; +$myownurl =~ s/http:\/\/(.*):(.*)/$1/; +($myownurl) = gethostbyname($myownurl); +$myownurl = "http://".$myownurl.":".$myownport; + tie(%map, 'DB_File', $uris_dbm.".db", O_RDONLY, 0664); -print "Please contact me at: url, ">\n"; +print "Please contact me at: \n"; print "helm_dir: $helm_dir\n"; +print "style_dir: $style_dir\n"; print "dtd_dir: $dtd_dir\n"; print "urls_of_uris.db: $uris_dbm.db\n"; print "cache mode: $cachemode\n"; @@ -220,21 +233,47 @@ EOT print "Using local copy\n"; open(FD, $filename) or die "Cannot open $filename\n"; $cont = ""; - while() { $cont .= $_; } + while() { + # Vary bad heuristic for substituion of absolute URLs + # for relative ones + s/ENTITY (.*) SYSTEM\s+"/ENTITY $1 SYSTEM "$myownurl\/getdtd?uri=/g; + $cont .= $_; + } close(FD); answer($c,$cont); } else { die "Could not find DTD!"; } - } elsif ($http_method eq 'GET' and $http_path eq "/getxslt") { + } elsif ($http_method eq 'GET' and $http_path eq "/getstyleconf") { + my $filename = $inputuri; + $filename = $style_dir."/config/".$filename; + if (stat($filename)) { + open(FD, $filename) or die "Cannot open $filename\n"; + $cont = ""; + while() { + s/DOCTYPE (.*) SYSTEM\s+"/DOCTYPE $1 SYSTEM "$myownurl\/getstyleconf?uri=/g; + $cont .= $_; + } + close(FD); + answer($c,$cont); + } else { + die "Could not find Style Configuration File!"; + } + } elsif ($http_method eq 'GET' and $http_path eq "/getxslt") { my $filename = $inputuri; - $filename = $styles_dir."/".$filename; + $filename = $style_dir."/".$filename; print "XSLT: $inputuri ==> ($filename)\n"; if (stat($filename)) { print "Using local copy\n"; open(FD, $filename) or die "Cannot open $filename\n"; $cont = ""; - while() { $cont .= $_; } + while() { + # Vary bad heuristic for substituion of absolute URLs + # for relative ones + s/xsl:import\s+href="/xsl:import href="$myownurl\/getxslt?uri=/g ; + s/xsl:include\s+href="/xsl:include href="$myownurl\/getxslt?uri=/g ; + $cont .= $_; + } close(FD); answer($c,$cont); } else { @@ -256,6 +295,9 @@ EOT kill(USR1,getppid()); 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."

"); } else { print "\nINVALID REQUEST!!!!!\n"; $c->send_error(RC_FORBIDDEN)