Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

LWP proxy user authentication

by imrags (Monk)
on May 26, 2011 at 10:49 UTC ( [id://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('http://proxy.srvr.com:8080/','domain',$user=>$p +wd); my $url = 'http://www.google.com'; 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?
Raghu

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=http://proxy.srvr.com:8080/
    Then run your script:
    #!/usr/bin/perl use strict; use warnings; use LWP::UserAgent; my $url = 'http://www.google.com'; my $user = 'user'; my $pass = 'pass'; my $domain = 'domain'; my $ua = LWP::UserAgent->new(); $ua->env_proxy; $ua->credentials('proxy.srvr.com:8080', $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?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://906804]
Approved by SilasTheMonk
Front-paged by toolic
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (5)
As of 2024-04-23 23:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found