Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Specifying User and Password for HTTP::Request object.

Status
Not open for further replies.

awolff01

Programmer
Jun 17, 2003
55
0
0
US
HTTP:Request::Common
LWP::UserAgent
XML::Simple.

I am using the above modules to makes calls to a and parsing the return xml data. But the web server requires authentication how do I specify the username and password when making the Http Request?


Thank You.
 
#!/usr/bin/perl -w

use strict;

use HTTP::Request::Common;
use LWP::UserAgent;

my $url = "
my $agent = LWP::UserAgent->new;
my $req = HTTP::Request->new;

$req->method('POST');
$req->uri($url);
$req->authorization_basic('username','password');

my $content = $agent->request($req)->as_string;

# Return the request
print "content-type: text/html\n\n";
print $content;
print $req->as_string;

M. Brooks
X Concepts LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top