1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
|
package OAuth::Lite2::Agent;
use strict;
use warnings;
use LWP::UserAgent;
=head1 NAME
OAuth::Lite2::Agent - Base class of preset-agents.
=head1 SYNOPSIS
my $agent = OAuth::Lite2::Client::Agent->new;
my $res = $agent->request( $req );
=head1 DESCRIPTION
Base class of preset-agents.
=head1 METHODS
=head2 new (%args)
Constructor you can set 'agent' that has same 'request' interface method as LWP::UserAgent.
If you omit that, a simple LWP::UserAgent object is set by default.
my $agent = $class->new( agent => YourCustomAgent->new );
=cut
sub new {
my $class = shift;
my $self = bless { @_ }, $class;
unless ($self->{agent}) {
$self->{agent} = LWP::UserAgent->new;
$self->{agent}->agent(
join "/",
__PACKAGE__,
$OAuth::Lite2::Client::VERSION
);
}
return $self;
}
=head2 request ($req)
Returns L<HTTP::Response> object.
=cut
sub request {
my ($self, $req) = @_;
return $self->{agent}->request($req);
}
1;
=head1 SEE ALSO
L<OAuth::Lite2::Client::Agent::Dump>,
L<OAuth::Lite2::Client::Agent::Strict>
=head1 AUTHOR
Lyo Kato, C<lyo.kato _at_ gmail.com>
=head1 COPYRIGHT AND LICENSE
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself, either Perl version 5.8.8 or,
at your option, any later version of Perl 5 you may have available.
=cut
|