Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
Perl: the Markov chain saw
 
PerlMonks  

Re: LWP::UserAgent and private proxy servers

by tachyon (Chancellor)
on Dec 02, 2004 at 03:40 UTC ( [id://411687]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to LWP::UserAgent and private proxy servers

It may be as simple as doing this:

$ua->proxy(["http"], "http://username:password@proxy.com");

Or you may find that this code (which does 401 authentication for you) does what you want.

my $ua = LWP::Custom->new(); $ua->proxy(["http"], "http://proxy.com"); $ua->set_basic_credentials( $user, $pass ); package LWP::Custom; use base 'LWP::UserAgent'; # add a set_basic_credentials method, using a closure to remember { my ( $username, $password ); sub set_basic_credentials{ ( $username, $password ) = @_[1..2] } sub get_basic_credentials{ $username, $password }; }

cheers

tachyon

Replies are listed 'Best First'.
Re^2: LWP::UserAgent and private proxy servers
by Anonymous Monk on Dec 02, 2004 at 05:27 UTC
    is that documented?
      It sure is. Read the proxy attributes section of the documentation.

      davidj
Re^2: LWP::UserAgent and private proxy servers
by theloanarranger (Acolyte) on Dec 02, 2004 at 22:41 UTC
    Tachyon,

    Thank you so much for your help. The first idea didn't work because LWP::UserAgent couldn't handle the username and password within the url, but the second idea worked wonderfully and you showed me how to extend classes.
    Thanks again,

    Matt Schick

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://411687]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.