brian 98/05/04 20:15:34
Added: uri-res N2L.cgi Log: Added a URN->URL resolution program provided by the Squid developers. Let's see if this works! Revision Changes Path 1.1 apache-site/uri-res/N2L.cgi Index: N2L.cgi =================================================================== #!/usr/local/bin/perl $mirfile = '/pub/apache/mirrors/mirrors.list'; print "Content-type: text/plain\r\n"; print "Expires: ", &http_time(time+3600), "\r\n"; print "\r\n"; if ($ENV{'REQUEST_METHOD'} eq "POST") { read(STDIN, $request, $ENV{'CONTENT_LENGTH'}); } elsif ($ENV{'REQUEST_METHOD'} eq "GET" ) { $request = $ENV{'QUERY_STRING'}; } $request = &url_decode($request); # # special hack; turn 'urn:foo' into 'urn:foo:/' # $request .= ':/' unless ($request =~ /([^:]+):([^:]+):/); #$state = 0; open(MIRR, $mirfile) || die "can't open mirror file!"; while (<MIRR>) { chop; next if (/^#/); next unless (/./); # We have two URN's, www.apache.org and ftp.apache.org. # Soak them up into two arrays, then blast them out. ($scheme, $country, $url, $admin) = split(/\s+/); $urns{$scheme} .= "$url\n"; } if ($request =~ /www.apache.org/) { print "$urns{'http'}" } elsif ($request =~ /ftp.apache.org/) { print "$urns{'ftp'}" } exit 0; sub url_decode { local($_) = @_; tr/+/ /; s/%(..)/pack("c",hex($1))/ge; $_; } sub http_time { local($t) = @_; local(@T) = gmtime($t); local(@WD) = ('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'); local(@MO) = ( 'Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'); sprintf "%s, %d %s %d %02d:%02d:%02d GMT", $WD[$T[6]], $T[3], $MO[$T[4]], $T[5], $T[2],$T[1],$T[0]; }