1

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?

myselfmiqdad
  • 2,518
  • 2
  • 18
  • 33
user3540276
  • 139
  • 3
  • 10
  • Is the question if you can use POE with (Basic Authentication)[https://en.wikipedia.org/wiki/Basic_access_authentication]? – bolav Jan 05 '16 at 09:39
  • yes i would like to use poe::component::client:http compenent with basic authentication – user3540276 Jan 05 '16 at 09:53

1 Answers1

0

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.

bolav
  • 6,938
  • 2
  • 18
  • 42
  • i like the same authentication as like we do in lwp agent , which includes host-port address, realm string , username and password. – user3540276 Jan 06 '16 at 07:57
  • @user3540276: Yes. Then you need to find a component that does that, or implement it yourself. – bolav Jan 06 '16 at 10:32
  • i want digest auth system to be injected in my request headers – user3540276 Jan 06 '16 at 10:51
  • Is there a way so that i can inject lwp agent in poe::component::client:http – user3540276 Jan 06 '16 at 10:56
  • 1
    No. There is no easy way of using LWP::UserAgent. You could look at https://metacpan.org/source/ETHER/libwww-perl-6.15/lib/LWP/Authen/Digest.pm to see how LWP implements Digest. – bolav Jan 06 '16 at 11:13