Changeset 31878 for main/trunk/greenstone2
- Timestamp:
- 2017-08-11T18:22:36+12:00 (7 years ago)
- Location:
- main/trunk/greenstone2/perllib/downloaders
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/downloaders/WebDownload.pm
r31877 r31878 193 193 my $strBaseCMD = $strOptions." --tries=2 -q -O - \"$self->{'url'}\""; 194 194 195 196 197 195 #&util::print_env(STDERR, "https_proxy", "http_proxy", "HTTPS_PROXY", "HTTP_PROXY", "ftp_proxy", "FTP_PROXY"); 196 #&util::print_env(STDERR); 197 198 198 my $strIdentifyText = $self->useWget($strBaseCMD); 199 199 -
main/trunk/greenstone2/perllib/downloaders/WgetDownload.pm
r31877 r31878 169 169 sub addProxySettingsAsWgetFlags 170 170 { 171 my ($self) = @_;172 my $strOptions = "";173 174 if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'})175 {176 $strOptions .= " -e https_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} ";177 $strOptions .= " -e http_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} ";178 179 if ($self->{'user_name'} && $self->{'user_password'})180 {181 $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}";182 }183 }184 185 if ($self->{'proxy_on'}) {186 $strOptions .= " --proxy ";187 }188 189 return $strOptions;190 }191 192 sub getWgetOptions193 {194 171 my ($self) = @_; 195 172 my $strOptions = ""; 196 173 197 # If proxy settings are set up in the environment, wget is ready to use them. More secure. 198 # But if proxy settings are not set up in the environment, pass them as flags to wget 199 # This is less secure, as pwd etc visible in task manager, but it was the original way in 200 # which wget was run on windows. 201 # Truth in Perl: https://home.ubalt.edu/abento/452/perl/perltruth.html 174 if ($self->{'proxy_on'} && $self->{'proxy_host'} && $self->{'proxy_port'}) 175 { 176 $strOptions .= " -e https_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} "; 177 $strOptions .= " -e http_proxy=$self->{'proxy_host'}:$self->{'proxy_port'} "; 178 179 if ($self->{'user_name'} && $self->{'user_password'}) 180 { 181 $strOptions .= "--proxy-user=$self->{'user_name'}"." --proxy-passwd=$self->{'user_password'}"; 182 } 183 } 184 185 if ($self->{'proxy_on'}) { 186 $strOptions .= " --proxy "; 187 } 188 189 return $strOptions; 190 } 191 192 sub getWgetOptions 193 { 194 my ($self) = @_; 195 my $strOptions = ""; 196 197 # If proxy settings are set up in the environment, wget is ready to use them. More secure. 198 # But if proxy settings are not set up in the environment, pass them as flags to wget 199 # This is less secure, as pwd etc visible in task manager, but it was the original way in 200 # which wget was run on windows. 201 # Truth in Perl: https://home.ubalt.edu/abento/452/perl/perltruth.html 202 202 # http://www.perlmonks.org/?node=what%20is%20true%20and%20false%20in%20Perl%3F 203 203 204 204 if (!$ENV{'http_proxy'} && !$ENV{'https_proxy'}) { 205 205 $strOptions .= $self->addProxySettingsAsWgetFlags(); 206 206 } # else wget will use proxy settings in environment, assume enough settings have been provided 207 208 if($self->{'no_check_certificate'}) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http 207 209 208 if($self->{'no_check_certificate'}) { # URL may be http that gets redirected to https, so if no_check_certificate is on, turn it on even if URL is http209 210 210 $strOptions .= " --no-check-certificate "; 211 211 } 212 212 213 213 return $strOptions; 214 214 } … … 288 288 # closing an extra unused handle, a single handle is used instead for both the child's 289 289 # stderr and stdout. 290 291 290 # See http://blog.0x1fff.com/2009/09/howto-execute-system-commands-in-perl.html 291 # for why this is the right thing to do. 292 292 293 293 # Both open2 and open3 don't return on failure, but raise an exception. The handling
Note:
See TracChangeset
for help on using the changeset viewer.