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 MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

HTTP Authorization

Status
Not open for further replies.

Smersh2000

IS-IT--Management
Dec 28, 2004
5
US
Hello,

I have some experience in Perl, but this is the first time i deal with HTTP requests. Here is my problem - i'm trying to send a PUT request using LWP::UserAgent. Everything is working fine - the file gets posted (i'm working with eXist DB through REST), as long as i'm working in open collection (that is guest user can modify and create documents. I need to be able to make the PUT request as an authorized user. How do i do this using HTTP:Headers? I've been sitting here trying to figure it out for a while, but wasn't able to get any examples. CPAN entry for HTTP::Headers gives a list of functions but not a single example on how to use it.

Any help is much appreciated!

Thanks,

TS
 
right out of the documentation:

Examples:

$header->header(MIME_Version => '1.0',
User_Agent => 'My-Web-Client/0.01');
$header->header(Accept => "text/html, text/plain, image/*");
$header->header(Accept => [qw(text/html text/plain image/*)]);
@accepts = $header->header('Accept'); # get multiple values
$accepts = $header->header('Accept'); # get values as a single string

I don't understand your question well enough (well, really not at all) to know if this is the correct module for the task.

Maybe look into



- Kevin, perl coder unexceptional!
 
Kevin,

thank you for lookin at it, and I am sorry for not being clear enough. I actually got everythin figured out. The function i was looking for was HTTP::Headers->authorization_basic ($username, $password), and what confused me is the fact that that function in CPAN is shown with something like this:

$h = HTTP::Headers->new;
$h->header('Content-Type' => 'text/plain');
$h->authorization_basic($username, $password);

but in examples (which i was finally able to find) it's used as:

$req = HTTP::Request->new(POST=>$server)
$req->content_type('text/xml');
$req->content($query);
$req->authorization_basic($username, $password);

After looking at CPAN i assumed that i had to create header object and then assign it to the request object. Turned out i can use authorization_basic directly on the request.

Thanks for looking at this though,

TS
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top