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

raeburn raeburn at source.lon-capa.org
Sun Jan 2 20:51:09 EST 2022


raeburn		Mon Jan  3 01:51:09 2022 EDT

  Modified files:              (Branch: version_2_11_X)
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - For 2.11
    Backport additional part of 1.1447, omitted from changes in 1.1172.2.142.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1172.2.144 loncom/lonnet/perl/lonnet.pm:1.1172.2.145
--- loncom/lonnet/perl/lonnet.pm:1.1172.2.144	Fri Dec 24 21:13:15 2021
+++ loncom/lonnet/perl/lonnet.pm	Mon Jan  3 01:51:09 2022
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1172.2.144 2021/12/24 21:13:15 raeburn Exp $
+# $Id: lonnet.pm,v 1.1172.2.145 2022/01/03 01:51:09 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -3167,11 +3167,29 @@
 # --------------------------------------------------------- Server Side Include
 
 sub absolute_url {
-    my ($host_name) = @_;
+    my ($host_name,$unalias,$keep_proto) = @_;
     my $protocol = ($ENV{'SERVER_PORT'} == 443?'https://':'http://');
     if ($host_name eq '') {
 	$host_name = $ENV{'SERVER_NAME'};
     }
+    if ($unalias) {
+        my $alias = &get_proxy_alias();
+        if ($alias eq $host_name) {
+            my $lonhost = $perlvar{'lonHostID'};
+            my $hostname = &hostname($lonhost);
+            my $lcproto;
+            if (($keep_proto) || ($hostname eq '')) {
+                $lcproto = $protocol;
+            } else {
+                $lcproto = $protocol{$lonhost};
+                $lcproto = 'http' if ($lcproto ne 'https');
+                $lcproto .= '://';
+            }
+            unless ($hostname eq '') {
+                return $lcproto.$hostname;
+            }
+        }
+    } 
     return $protocol.$host_name;
 }
 
@@ -3188,12 +3206,13 @@
 sub ssi {
 
     my ($fn,%form)=@_;
-    my ($request,$response);
+    my ($host,$request,$response);
+    $host = &absolute_url('',1);
 
     $form{'no_update_last_known'}=1;
     &Apache::lonenc::check_encrypt(\$fn);
     if (%form) {
-      $request=new HTTP::Request('POST',&absolute_url().$fn);
+      $request=new HTTP::Request('POST',$host.$fn);
       $request->content(join('&',map {
             my $name = escape($_);
             "$name=" . ( ref($form{$_}) eq 'ARRAY'
@@ -3201,7 +3220,7 @@
             : &escape($form{$_}) );
         } keys(%form)));
     } else {
-      $request=new HTTP::Request('GET',&absolute_url().$fn);
+      $request=new HTTP::Request('GET',$host.$fn);
     }
 
     $request->header(Cookie => $ENV{'HTTP_COOKIE'});




More information about the LON-CAPA-cvs mailing list