Client/Connection.pm

filter: Statementstmt 44.4% 16 / 36 Branchbran 0.0% 0 / 10 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 36.3% 4 / 11 Podpod 0.0% 0 / 3 totaltotal 26.6% 20 / 75 CC 9 SCAR 28.0
CC
9
Cov
29%
_http_response_code
30.0
_request
30.0
__ANON__
2.0
CRAP 16.5
↑ Summary Client/Document.pm »
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
BranchTrueFalseTotal
if $code == 200 or $code == 409 0 0 0
Condition0%0/3
$code == 200 or $code == 409
l!l&&r!l&&!r
000
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
ABresult
1X1
011
000
38 0 ▶ return 0 if $code == HTTP_CREATED && $method eq 'PUT';
Branch: 1 branch
BranchTrueFalseTotal
if $code == 201 and $method eq "PUT" 0 0 0
Condition0%0/3
$code == 201 and $method eq "PUT"
!ll&&!rl&&r
000
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"
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if ($method eq "PUT") 0 0 0
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
BranchTrueFalseTotal
if $method ne "DELETE" 0 0 0
58 if $method ne "DELETE";
59  
60 0 ▶ return ($method eq 'GET' || $response->code == HTTP_CONFLICT)
Branch: 1 branch
BranchTrueFalseTotal
$method eq 'GET' || $response->code == 409 ? : 0 0 0
Condition0%0/3
$method eq "GET" or $response->code == 409
l!l&&r!l&&!r
000
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
ABresult
1X1
011
000
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  
↑ Summary Client/Document.pm »