Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

LWP proxy user authentication

by imrags (Monk)
on May 26, 2011 at 10:49 UTC ( #906804=perlquestion: print w/replies, xml ) Need Help??
imrags has asked for the wisdom of the Perl Monks concerning the following question:

Hello monks

I'm trying to write a simple code which will get details of the website using LWP.
We've a proxy server and it needs user credentials (AD)...
I've written the code below but the script just hangs:
use LWP::Simple; use LWP::UserAgent; my $user = 'user'; my $pwd = 'password'; my $browser = LWP::UserAgent->new(); $browser->credentials('','domain',$user=>$p +wd); my $url = ''; my $response = $browser->get($url); print $response->header("Server"),"\n";
I also tried using basic_authorization, http::headers etc.
I am pretty sure it's the problem with proxy... Any help?

Replies are listed 'Best First'.
Re: LWP proxy user authentication
by Khen1950fx (Canon) on May 27, 2011 at 07:39 UTC
    I noticed that you used LWP::Simple. You can take that out. I also noticed that you used $pwd for password---that's confusing because pwd stands for "present working directory", so change that to $pass.

    The main problem that I see with your code is that you need to explicitly say that you're behind a proxy. What I would do is set the environmental variable for http_proxy. Here you could do:

    export http_proxy=
    Then run your script:
    #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $url = ''; my $user = 'user'; my $pass = 'pass'; my $domain = 'domain'; my $ua = LWP::UserAgent->new(); $ua->env_proxy; $ua->credentials('', $domain, $user, $pass); my $res = $ua->get($url); print $res->header("Server"), "\n";
Re: LWP proxy user authentication
by Anonymous Monk on May 26, 2011 at 11:07 UTC
    turn on debugging/tracing or whip out the wireshark

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://906804]
Approved by SilasTheMonk
Front-paged by toolic
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2016-12-10 12:28 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (162 votes). Check out past polls.