From: Josef Moellers on
I'm trying to use LWP::UserAgent on Kubuntu 10.04.

When setting a proxy, I use this code to load my wget's proxy settings:

if (open(my $wgetrc, '<', $ENV{HOME} . '/.wgetrc')) {
while (<$wgetrc>) {
if (/(http|ftp|https)_proxy\s*=\s*(\S+)/) {
print STDERR "\$ua->proxy($1, $2)\n";
my $old = $ua->proxy($1, $2);
print "... was ", $old ? $old : 'None', "\n";
# push @protocols_allowed, $1;
next;
} elsif (/user-agent\s*=\s*(\S.*\S)\s*$/) {
print STDERR "\$ua->agent($1)\n";
$ua->agent($1);
}
}
close $wgetrc;
}

The prints all come out OK, showing the proxy URLs like
$ua->proxy(http, http://<proxy-address>:81/)
$ua->proxy(https, http://<proxy-address>:81/)
$ua->proxy(ftp, http://<proxy-address>:81/)

However, a $ua->get('http://www.google.de/') fails.

I've taken the liberty (being root ;-) to insert a few prints into the
sub proxy in /usr/share/perl5/LWP/UserAgent.pm and found that prior to
the Carp::croak("'$key' is not a valid URI scheme") unless $key =~
/^$URI::scheme_re\z/;
@_ contained the proxy-URL and after that command, @_[0] is empty!

When I comment that line, the $ua->get('http://www.google.de/') succeeds.

Does anybody have an idea what happens?

Josef
--
These are my personal views and not those of Fujitsu Technology Solutions!
Josef M´┐Żllers (Pinguinpfleger bei FTS)
If failure had no penalty success would not be a prize (T. Pratchett)
Company Details: http://de.ts.fujitsu.com/imprint.html