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

raeburn raeburn@source.lon-capa.org
Fri, 19 Dec 2008 17:04:57 -0000


raeburn		Fri Dec 19 17:04:57 2008 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Entries for LON-CAPA DNS servers in hosts.tab can contain a protocol (https), seperated from the hostname by :
  - Default is http if no protocol defined
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.978 loncom/lonnet/perl/lonnet.pm:1.979
--- loncom/lonnet/perl/lonnet.pm:1.978	Thu Dec 18 16:58:31 2008
+++ loncom/lonnet/perl/lonnet.pm	Fri Dec 19 17:04:57 2008
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.978 2008/12/18 16:58:31 raeburn Exp $
+# $Id: lonnet.pm,v 1.979 2008/12/19 17:04:57 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8648,14 +8648,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);