[LON-CAPA-cvs] cvs: loncom(version_2_8_X) /lonnet/perl lonnet.pm

raeburn raeburn@source.lon-capa.org
Sun, 21 Dec 2008 15:20:55 -0000


raeburn		Sun Dec 21 15:20:55 2008 EDT

  Modified files:              (Branch: version_2_8_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Backport 1.980.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.976.2.1 loncom/lonnet/perl/lonnet.pm:1.976.2.2
--- loncom/lonnet/perl/lonnet.pm:1.976.2.1	Thu Dec 18 17:43:53 2008
+++ loncom/lonnet/perl/lonnet.pm	Sun Dec 21 15:20:54 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.976.2.1 2008/12/18 17:43:53 raeburn Exp $
+# $Id: lonnet.pm,v 1.976.2.2 2008/12/21 15:20:54 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8617,14 +8617,19 @@
     open(my $config,"<$perlvar{'lonTabDir'}/hosts.tab");
     foreach my $dns (<$config>) {
 	next if ($dns !~ /^\^(\S*)/x);
-	$alldns{$1} = 1;
+        my $line = $1;
+        my ($host,$protocol) = split(/:/,$line);
+        if ($protocol ne 'https') {
+            $protocol = 'http';
+        }
+	$alldns{$host} = $protocol;
     }
     while (%alldns) {
 	my ($dns) = keys(%alldns);
-	delete($alldns{$dns});
 	my $ua=new LWP::UserAgent;
-	my $request=new HTTP::Request('GET',"http://$dns$url");
+	my $request=new HTTP::Request('GET',"$alldns{$dns}://$dns$url");
 	my $response=$ua->request($request);
+        delete($alldns{$dns});
 	next if ($response->is_error());
 	my @content = split("\n",$response->content);
 	&Apache::lonnet::do_cache_new('dns',$url,\@content,30*24*60*60);