Subject: | http_proxy, proxy_user, and proxy_pass is not used with curl |
Hi,
I'm using version 1.9205 of CPAN.pm. I would like to make a few
suggestions to improve the experiences of those living behind HTTP proxies.
Firstly, thank you for adding support for curl!
Inside CPAN::FTP::hostdlhard():
Change this block:
} elsif ($f eq 'curl') {
$src_switch = ' -L -f -s -S --netrc-optional';
# BEGIN NEW CODE
my $http_proxy = $CPAN::Config->{ 'http_proxy' } ;
if ($http_proxy !~ m/^\s*$/)
{
my($proxy_user, $proxy_pass) =
&CPAN::LWP::UserAgent::get_proxy_credentials() ;
$src_switch .= " -U \"$proxy_user:$proxy_pass\" -x
\"$http_proxy\"" ;
}
# END NEW CODE
}
Inside CPAN::LWP::UserAgent::get_proxy_credentials():
sub get_proxy_credentials {
my $self = shift;
my ($user, $password);
# You need to add the length() checks. I have a blank password in my
# CPAN config, but it doesn't prompt. That doesn't seem right.
if ( defined $CPAN::Config->{proxy_user} &&
$CPAN::Config->{proxy_user}) !~ m/^\s*$/ &&
defined $CPAN::Config->{proxy_pass} &&
$CPAN::Config->{proxy_pass}) !~ m/^\s*$/ {
$user = $CPAN::Config->{proxy_user};
$password = $CPAN::Config->{proxy_pass};
return ($user, $password);
}
The same code also needs to be changed for
CPAN::LWP::UserAgent::get_non_proxy_credentials().
Also inside CPAN::LWP::UserAgent::_get_username_and_password_from_user():
You should only prompt for user if it is missing and the same for
password. At least show the user as the default when prompting again.
Probably this needs some kind of cache, otherwise users are forced to
enter their credentials many, many times as files are downloaded.
Thanks and keep up the great work!
Kevin