Diff for /loncom/lonnet/perl/lonnet.pm between versions 1.941.2.2 and 1.942

version 1.941.2.2, 2008/04/04 16:58:44 version 1.942, 2008/02/21 10:04:35
Line 1631  sub ssi_body { Line 1631  sub ssi_body {
     if (! exists($form{'LONCAPA_INTERNAL_no_discussion'})) {      if (! exists($form{'LONCAPA_INTERNAL_no_discussion'})) {
         $form{'LONCAPA_INTERNAL_no_discussion'}='true';          $form{'LONCAPA_INTERNAL_no_discussion'}='true';
     }      }
     my $output='';      my $output=($filelink=~/^http\:/?&externalssi($filelink):
     my $response;                                       &ssi($filelink,%form));
     if ($filelink=~/^http\:/) {  
         ($output,$response)=&externalssi($filelink);  
     } else {  
         ($output,$response)=&ssi($filelink,%form);  
     }  
     $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+?// END LON-CAPA Internal\s*(-->)?\s||gs;      $output=~s|//(\s*<!--)? BEGIN LON-CAPA Internal.+?// END LON-CAPA Internal\s*(-->)?\s||gs;
     $output=~s/^.*?\<body[^\>]*\>//si;      $output=~s/^.*?\<body[^\>]*\>//si;
     $output=~s/\<\/body\s*\>.*?$//si;      $output=~s/\<\/body\s*\>.*?$//si;
     if (wantarray) {      return $output;
         return ($output, $response);  
     } else {  
         return $output;  
     }  
 }  }
   
 # --------------------------------------------------------- Server Side Include  # --------------------------------------------------------- Server Side Include
Line 1665  sub absolute_url { Line 1656  sub absolute_url {
 #  fn     Possibly encrypted resource name/id.  #  fn     Possibly encrypted resource name/id.
 #  form   Hash that describes how the rendering should be done  #  form   Hash that describes how the rendering should be done
 #         and other things.  #         and other things.
 # Returns:  #  r      Optional reference that will be given the response.
 #   Scalar context: The content of the response.  #         This is mostly provided so that the caller can implement
 #   Array context:  2 element list of the content and the full response object.  #         error detection, recovery and retry policies.
 #       #     
   # Returns:
   #    The content of the response.
 sub ssi {  sub ssi {
   
     my ($fn,%form)=@_;      my ($fn,%form, $r)=@_;
   
     my $ua=new LWP::UserAgent;      my $ua=new LWP::UserAgent;
       
     my $request;      my $request;
   
     $form{'no_update_last_known'}=1;      $form{'no_update_last_known'}=1;
Line 1687  sub ssi { Line 1682  sub ssi {
     $request->header(Cookie => $ENV{'HTTP_COOKIE'});      $request->header(Cookie => $ENV{'HTTP_COOKIE'});
     my $response=$ua->request($request);      my $response=$ua->request($request);
   
     if (wantarray) {      if ($r) {
  return ($response->content, $response);   $$r = $response;
     } else {  
  return $response->content;  
     }      }
   
       return $response->content;
 }  }
   
 sub externalssi {  sub externalssi {
Line 1699  sub externalssi { Line 1694  sub externalssi {
     my $ua=new LWP::UserAgent;      my $ua=new LWP::UserAgent;
     my $request=new HTTP::Request('GET',$url);      my $request=new HTTP::Request('GET',$url);
     my $response=$ua->request($request);      my $response=$ua->request($request);
     if (wantarray) {      return $response->content;
         return ($response->content, $response);  
     } else {  
         return $response->content;  
     }  
 }  }
   
 # -------------------------------- Allow a /uploaded/ URI to be vouched for  # -------------------------------- Allow a /uploaded/ URI to be vouched for

Removed from v.1.941.2.2  
changed lines
  Added in v.1.942


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>