File: Agent.pm

package info (click to toggle)
libweb-solid-auth-perl 0.91-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 360 kB
  • sloc: perl: 1,344; makefile: 5; sh: 1
file content (64 lines) | stat: -rw-r--r-- 1,852 bytes parent folder | download | duplicates (2)
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;