Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask

Re: HTTP::Headers, HTTP::Request, Authentication, LWP::Useragent

by Daddio (Chaplain)
on Mar 28, 2001 at 07:25 UTC ( #67732=note: print w/replies, xml ) Need Help??

in reply to HTTP::Headers, HTTP::Request, Authentication, LWP::Useragent

I don't know if I am understanding completely, but it sounds like you need to provide a username and password for a site? If that is the case, LWP::UserAgent has the authorization_basic method that can be used something like this (directly from the lwpcook manpage):

Documents protected by basic authorization can easily be accessed like this:
use LWP::UserAgent; $ua = LWP::UserAgent->new; $req = HTTP::Request->new(GET => ''); $req->authorization_basic('myuid', 'mypassword'); print $ua->request($req)->as_string;

The other alternative is to provide a subclass of LWP::UserAgent that overrides the get_basic_credentials() method. Study the lwp-request program for an example of this.

Hope that helps.

Replies are listed 'Best First'.
Re (tilly) 2: HTTP::Headers, HTTP::Request, Authentication, LWP::Useragent
by tilly (Archbishop) on Mar 28, 2001 at 09:42 UTC
    For one-off scripts it usually is really nice to use the fact that URLs have an optional "name:password@" between the protocol and the domain name. So you can write a URL like this:

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://67732]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (3)
As of 2018-11-17 01:07 GMT
Find Nodes?
    Voting Booth?
    My code is most likely broken because:

    Results (201 votes). Check out past polls.

    • (Sep 10, 2018 at 22:53 UTC) Welcome new users!