User authentication using POE::Component::Client::HTTP

153 Views Asked by At

I am trying to find a module in perl poe which can do user authentication while making a HTTP request.

HTTP request should be non-blocking

or

How should I use poe::component::client:http to do user authentication by providing username , password details?

1

There are 1 best solutions below

5
bolav On BEST ANSWER

You can pass a HTTP::Request object to POE::Component::Client::HTTP. Basic Auth is solved with a header, and can be sent as a header:

 use strict;
 use warnings;
 use MIME::Base64;
 use HTTP::Request;

 my $username = 'username';
 my $password = 'password';
 my $auth = 'Basic ' . MIME::Base64::encode($username . ':' . $password);

 my $request = HTTP::Request->new(GET => 'http://www.example/',
    [Authorization => $auth]);

And then just pass the $request to $poe_kernel->post as in the documentation.