| 1 | |||||||||||||||||||||||||||||
| 2 | package XCAP::Client::Connection; | ||||||||||||||||||||||||||||
| 3 | |||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use Moose; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 3 | ▶ | use LWP::UserAgent; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use URI::Split qw(uri_split); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 8 | 3 | ▶ | use HTTP::Status qw(:constants status_message); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | 3 | has ['uri', 'auth_realm', 'auth_username','auth_password', 'content'] => ( | |||||||||||||||||||||||||||
| 11 | is => 'rw', | ||||||||||||||||||||||||||||
| 12 | isa => 'Str' | ||||||||||||||||||||||||||||
| 13 | ); | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | has 'useragent' => ( | ||||||||||||||||||||||||||||
| 16 | is => 'rw', | ||||||||||||||||||||||||||||
| 17 | isa => 'Object', | ||||||||||||||||||||||||||||
| 18 | lazy => 1, | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | default => sub { LWP::UserAgent->new(agent => 'XCAP::Client') } | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 20 | 3 | ); | |||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | has 'netloc' => ( | ||||||||||||||||||||||||||||
| 23 | is => 'ro', | ||||||||||||||||||||||||||||
| 24 | isa => 'Str', | ||||||||||||||||||||||||||||
| 25 | lazy => 1, | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | default => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 27 | 0 | my $self = shift; | |||||||||||||||||||||||||||
| 28 | 0 | my ($scheme, $auth) = uri_split($self->uri); | |||||||||||||||||||||||||||
| 29 | 0 | $auth; | |||||||||||||||||||||||||||
| 30 | } | ||||||||||||||||||||||||||||
| 31 | 3 | ); | |||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | ▶ | sub _http_response_code () { | ||||||||||||||||||||||||||
|
Subroutine
_http_response_code: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 34 | 0 | my ($self, $method, $code) = @_; | |||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | # HTTP_CONFLICT - RFC 4825 - Section 11. | ||||||||||||||||||||||||||||
| 37 | 0 | ▶ | return 0 if $code == HTTP_OK || $code == HTTP_CONFLICT; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$code == 200 or $code == 409
MC/DC0%0/2
$code == 200 or $code == 409
$code == 200
$code == 409
Truth table0%0/3
A or B
A= $code == 200B= $code == 409
| |||||||||||||||||||||||||||||
| 38 | 0 | ▶ | return 0 if $code == HTTP_CREATED && $method eq 'PUT'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$code == 201 and $method eq "PUT"
MC/DC0%0/2
$code == 201 and $method eq "PUT"
$code == 201
$method eq "PUT"
Truth table0%0/3
A and B
A= $code == 201B= $method eq "PUT"
| |||||||||||||||||||||||||||||
| 39 | 0 | die status_message($code); | |||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||
| 41 | |||||||||||||||||||||||||||||
| 42 | 0 | ▶ | sub _request () { | ||||||||||||||||||||||||||
|
Subroutine
_request: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||
| 43 | 0 | my ($self, $method) = @_; | |||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||
| 45 | 0 | $self->useragent->credentials($self->netloc, $self->auth_realm, | |||||||||||||||||||||||||||
| 46 | $self->auth_username, $self->auth_password); | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | my $request = new HTTP::Request($method => $self->uri); | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | 0 | ▶ | if ($method eq 'PUT') { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 51 | 0 | $request->header('content-length' => length($self->content)); | |||||||||||||||||||||||||||
| 52 | 0 | $request->content($self->content); | |||||||||||||||||||||||||||
| 53 | } | ||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||
| 55 | 0 | my $response = $self->useragent->request($request); | |||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | 0 | ▶ | $self->_http_response_code($method,$response->code) | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 58 | if $method ne "DELETE"; | ||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | return ($method eq 'GET' || $response->code == HTTP_CONFLICT) | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$method eq "GET" or $response->code == 409
MC/DC0%0/2
$method eq "GET" or $response->code == 409
$method eq "GET"
$response->code == 409
Truth table0%0/3
A or B
A= $method eq "GET"B= $response->code == 409
| |||||||||||||||||||||||||||||
| 61 | ? $response->content : $response->code; | ||||||||||||||||||||||||||||
| 62 | } | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | |||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | 0 | ▶ | sub get { $_[0]->_request('GET'); } | ||||||||||||||||||||||||||
|
Subroutine
get: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||
| 68 | 0 | ▶ | sub delete { $_[0]->_request('DELETE'); } | ||||||||||||||||||||||||||
|
Subroutine
delete: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||
| 70 | 0 | ▶ | sub put { $_[0]->_request('PUT'); } | ||||||||||||||||||||||||||
|
Subroutine
put: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 3 | 1; | |||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||