Hi,
I'm new to this mailing list, and haven't yet found where y'all keep
the good documentation about dealing with an authenticating proxy
using LWP::UserAgent.
I have modeled a subclass approach on Gisle Aas' lwp-request.
You can see the complete script at
http://www.animalhead.com/maint_ip_world_db
maint_ip_world_db works fine on my FreeBSD server and Mac OS X
Leopard home system. Neither of these connect through an
authenticating proxy.
When I try this script from work under Cygwin, there is such a proxy
between my machine and the Internet. After the execution of the
following statements of interest:
my $ua = ourLWP->new (timeout => 30); # the start of the
web page above shows ourLWP
if ($proxy) { # $proxy is false
$ua->proxy(['http', 'ftp'], $proxy->as_string);
}
$resp = $ua->head($url);
I get a 500 "internal response", as shown in the following debugger
dumps:
DB<11> x $resp
0 HTTP::Response=HASH(0x10723bb0)
'_content' => '500 Can\'t connect to static.wipmania.com:80 (Bad
hostname \'static.wipmania.com\')'
'_headers' => HTTP::Headers=HASH(0x10723b98)
'client-date' => 'Thu, 25 Feb 2010 00:44:22 GMT'
'client-warning' => 'Internal response'
'content-type' => 'text/plain'
'_msg' => 'Can\'t connect to static.wipmania.com:80 (Bad hostname
\'static.wipmania.com\')'
'_rc' => 500
'_request' => HTTP::Request=HASH(0x106a2050)
'_content' => ''
'_headers' => HTTP::Headers=HASH(0x106a2038)
'user-agent' => 'libwww-perl/5.834'
'_method' => 'HEAD'
'_uri' => URI::http=SCALAR(0x1042dca0)
-> 'http://static.wipmania.com/static/worldip.en.text.zip'
DB<12> x $ua
0 ourLWP=HASH(0x105dde48)
'def_headers' => HTTP::Headers=HASH(0x105dd938)
'user-agent' => 'libwww-perl/5.834'
'handlers' => HASH(0x10635168)
'response_header' => HTTP::Config=ARRAY(0x106797e8)
0 HASH(0x10679e18)
'callback' => CODE(0x105ddde8)
-> &LWP::UserAgent::__ANON__[/usr/lib/perl5/
vendor_perl/5.10/LWP/UserAgent.pm:611] in /usr/lib/perl5/vendor_perl/
5.10/LWP/UserAgent.pm:590-611
'line' => '/usr/lib/perl5/vendor_perl/5.10/LWP/
UserAgent.pm:612'
'm_media_type' => 'html'
'owner' => 'LWP::UserAgent::parse_head'
'local_address' => undef
'max_redirect' => 7
'max_size' => undef
'no_proxy' => ARRAY(0x105e5048)
empty array
'protocols_allowed' => undef
'protocols_forbidden' => undef
'proxy' => HASH(0x1060eb60)
empty hash
'requests_redirectable' => ARRAY(0x105ddce0)
0 'GET'
1 'HEAD'
'show_progress' => undef
'timeout' => 30
'use_eval' => 1
DB<13>
Working through a callback in this way is more indirect than I had
hoped for.
I would have hoped, if my request got a 407 (Proxy Authentication
Required),
there would be a method or two that I could invoke to deal with the
situation.
Perhaps something named LWP::Authen::Basic which is listed in the
LWP documentation, but without a link so is it real?
When I copy the URI at the end of the dump of $resp, and paste it in a
browser, the content shows up fine, which fits in with the overall
script
working fine on my non-proxy, non-Cygwin systems.
Suggestions about how to debug this problem will be much appreciated.
Thanks,
cmac
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.