- my $res = new HTTP::Response;
- $res->content($cont);
- $c->send_response($res);
- }
- } elsif ($http_method eq 'GET' and $http_path eq "/annotate") {
- my $do_annotate = ($cicuri =~ /\.ann$/);
- my $target_to_annotate = $cicuri;
- $target_to_annotate =~ s/(.*)\.ann$/$1/ if $do_annotate;
- my $filename = $cicuri;
- $filename =~ s/cic:(.*)/$1/;
- $filename =~ s/theory:(.*)/$1/;
- my $filename_target = $helm_dir.$filename if $do_annotate;
- $filename = $helm_dir.$filename.".xml";
- $filename_target =~ s/(.*)\.ann$/$1.xml/ if $do_annotate;
- my $resolved = $map{$cicuri};
- my $resolved_target = $map{$target_to_annotate} if $do_annotate;
- if ($do_annotate) {
- print "($cicuri, $target_to_annotate) ==> ($resolved + $resolved_target) ($filename)\n";
- } else {
- print "$cicuri ==> $resolved ($filename)\n";
- }
-
- # Retrieves the annotation
-
- if (stat($filename)) {
- print "Using local copy for the annotation\n";
- open(FD, $filename);
- while(<FD>) { $cont .= $_; }
- close(FD);
- } else {
- print "Downloading the annotation\n";
- $ua = LWP::UserAgent->new;
- $request = HTTP::Request->new(GET => "$resolved");
- $response = $ua->request($request, \&callback);
-
- print "Storing file for the annotation\n";
- mkdirs($filename);
- open(FD, ">".$filename);
- print FD $cont;
- close(FD);
- }
- my $annotation = $cont;