Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

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?

Comment on LWP proxy user authentication
Download Code
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
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";

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (12)
As of 2015-03-02 16:03 GMT
Find Nodes?
    Voting Booth?

    When putting a smiley right before a closing parenthesis, do you:

    Results (50 votes), past polls