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
|
package Web::Solid::Auth::Agent;
use Moo;
extends 'LWP::UserAgent';
has auth => (
is => 'ro' ,
required => 1
);
sub get {
my ($self, $url , %opts ) = @_;
my $headers = $self->auth->make_authentication_headers($url,'GET');
%opts = (%opts, %$headers) if $headers;
return $self->SUPER::get($url,%opts);
}
sub head {
my ($self, $url , %opts ) = @_;
my $headers = $self->auth->make_authentication_headers($url,'HEAD');
%opts = (%opts, %$headers) if $headers;
return $self->SUPER::head($url,%opts);
}
sub options {
require HTTP::Request::Common;
my ($self, $url , %opts ) = @_;
my $headers = $self->auth->make_authentication_headers($url,'OPTIONS');
%opts = (%opts, %$headers) if $headers;
my @parameters = ($url, %opts);
my @suff = $self->_process_colonic_headers(\@parameters,1);
return $self->request( HTTP::Request::Common::OPTIONS( @parameters ), @suff );
}
sub delete {
my ($self, $url , %opts ) = @_;
my $headers = $self->auth->make_authentication_headers($url,'DELETE');
%opts = (%opts, %$headers) if $headers;
return $self->SUPER::delete($url,%opts);
}
sub post {
my ($self, $url ,$data, %opts ) = @_;
my $headers = $self->auth->make_authentication_headers($url,'POST');
%opts = (%opts, %$headers) if $headers;
return $self->SUPER::post($url,%opts, Content => $data);
}
sub put {
my ($self, $url ,$data, %opts ) = @_;
my $headers = $self->auth->make_authentication_headers($url,'PUT');
%opts = (%opts, %$headers) if $headers;
return $self->SUPER::put($url,%opts, Content => $data);
}
sub patch {
my ($self, $url ,$data, %opts ) = @_;
my $headers = $self->auth->make_authentication_headers($url,'PATCH');
%opts = (%opts, %$headers) if $headers;
return $self->SUPER::patch($url,%opts, Content => $data);
}
1;
|