Show
Ignore:
Timestamp:
09.08.2017 20:24:33 (2 years ago)
Author:
ak19
Message:

1. Modified GLI and perl to set proxy_on, proxy_host and proxy_port for unix too, whereas in the past, only http(s)_proxy ENV vars were set by GLI for unix. If the env vars are not set, then perl assumes it's the wget setup for windows and passes the proxy vars that were set by GLI as flags to wget. If the env vars were set, then perl should run wget without setting the proxy vars as flags to wget, and wget will use the proxying info in the environment. So now, the decision as to whether proxy vars are set or not will result in context specific suggestion messages to the user when the Server Info button was pressed and if the URL could not be accessed for whatever reason. 2. Modified GLI code to not use proxy if proxying is toggled off, but use proxy when it's toggled back on. (Previously, if proxying was set at any point during a GLI session, then GLI remembered that even when proxying was turned off thereafter.)

Location:
main/trunk/greenstone2/perllib/downloaders
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/downloaders/WebDownload.pm

    r31861 r31864  
    4040use strict; # every perl program should have this! 
    4141no strict 'refs'; # make an exception so we can use variables as filehandles 
    42 no strict 'subs'; 
     42no strict 'subs'; # to pass STDERR/STDOUT to functions 
     43 
    4344use gsprintf 'gsprintf'; 
    4445 
     
    192193    my $strBaseCMD = $strOptions." --tries=2 -q -O - \"$self->{'url'}\""; 
    193194 
    194     #print STDOUT "\n@@@@ GETTING server_info with WGET CMD: $strBaseCMD\n\n"; 
    195      
    196195    my $strIdentifyText = $self->useWget($strBaseCMD); 
    197196     
     
    200199    print STDERR "Server information is unavailable.\n"; 
    201200 
     201    #&util::print_env(STDERR, "https_proxy", "http_proxy"); 
     202     
    202203    if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) { # if proxying set, the settings may be wrong 
    203204        &gsprintf::gsprintf_multiline(STDERR, "{WebDownload.proxied_connect_failed_info}\n", $self->{'proxy_host'}, $self->{'proxy_port'}); 
  • main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm

    r31860 r31864  
    169169    my ($self) = @_; 
    170170    my $strOptions = ""; 
    171      
    172     if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) 
    173     { 
    174  
    175     if($self->{'url'} =~ m/^https\:/) { 
     171 
     172    # If http_proxy ENV VARS are not set, but proxy Perl vars are set, then we're on Windows 
     173    # and need to use the proxy vars as flags to wget 
     174    # If http_proxy Env Vars are set, then we're on Linux, wget will use the http(s) proxy 
     175    # env vars and we shouldn't be passing any proxy perl vars as flags 
     176     
     177    # Truth in Perl: https://home.ubalt.edu/abento/452/perl/perltruth.html 
     178    # http://www.perlmonks.org/?node=what%20is%20true%20and%20false%20in%20Perl%3F 
     179     
     180    if (!$ENV{'http_proxy'} && !$ENV{'https_proxy'}) { 
     181    if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) 
     182    { 
     183         
     184        if($self->{'url'} =~ m/^https\:/) { 
    176185        $strOptions .= " -e https_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} ";   
    177     } else { 
     186        } else { 
    178187        $strOptions .= " -e http_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} "; 
    179     }    
    180  
    181     if ($self->{'user_name'} && $self->{'user_password'}) 
    182     { 
    183         $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}"; 
    184     } 
    185     } 
    186  
    187     if ($self->{'proxy_on'}) { 
    188     $strOptions .= " --proxy "; 
    189     } 
    190  
    191     if($self->{'no_check_certificate'}) { #&& $self->{'url'} =~ m/^https\:/) { # URL may be http that gets redirected to https 
    192      
     188        }    
     189         
     190        if ($self->{'user_name'} && $self->{'user_password'}) 
     191        { 
     192        $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}"; 
     193        } 
     194    } 
     195 
     196    if ($self->{'proxy_on'}) { 
     197        $strOptions .= " --proxy "; 
     198    } 
     199    } 
     200 
     201    if($self->{'no_check_certificate'}) { #&& $self->{'url'} =~ m/^https\:/) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http 
     202 
    193203    $strOptions .= " --no-check-certificate "; 
    194204    } 
     
    259269    my $wget_file_path = &FileUtils::filenameConcatenate($ENV{'GSDLHOME'}, "bin", $ENV{'GSDLOS'}, "wget"); 
    260270    $command = "\"$wget_file_path\" $cmdWget"; 
    261     #print STDOUT "Command is: $command\n"; 
    262  
     271    #print STDOUT "Command is: $command\n"; # displayed in GLI output 
     272    #print STDERR "Command is: $command\n"; # goes into ServerInfoDialog 
     273     
    263274    # Wget's output needs to be monitored to find out when it has naturally terminated. 
    264275    # Wget's output is sent to its STDERR so we can't use open2 without doing 2>&1.