| 1 | package Net::OBEX; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 4 | our $VERSION = '1.001002'; # VERSION | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | 4 | ▶ | use Carp; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 4 | ▶ | use Socket::Class; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 4 | ▶ | use IO::Handle; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | 4 | ▶ | use Net::OBEX::Packet::Request; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 12 | 4 | ▶ | use Net::OBEX::Response; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | 4 | ▶ | use Net::OBEX::Packet::Headers; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 14 | 4 | ▶ | use Devel::TakeHashArgs; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | 4 | ▶ | use base qw(Class::Data::Accessor); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 17 | |||||||||||||||||||||||||||||||||||||||||||
| 18 | 4 | __PACKAGE__->mk_classaccessors( qw( | |||||||||||||||||||||||||||||||||||||||||
| 19 | sock | ||||||||||||||||||||||||||||||||||||||||||
| 20 | error | ||||||||||||||||||||||||||||||||||||||||||
| 21 | mtu | ||||||||||||||||||||||||||||||||||||||||||
| 22 | success | ||||||||||||||||||||||||||||||||||||||||||
| 23 | code | ||||||||||||||||||||||||||||||||||||||||||
| 24 | status | ||||||||||||||||||||||||||||||||||||||||||
| 25 | connection_id | ||||||||||||||||||||||||||||||||||||||||||
| 26 | obj_res | ||||||||||||||||||||||||||||||||||||||||||
| 27 | obj_head | ||||||||||||||||||||||||||||||||||||||||||
| 28 | obj_req | ||||||||||||||||||||||||||||||||||||||||||
| 29 | response | ||||||||||||||||||||||||||||||||||||||||||
| 30 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 31 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | 2 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | 2 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 35 | 2 | my $self = bless {}, $class; | |||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | 2 | $self->obj_head( Net::OBEX::Packet::Headers->new ); | |||||||||||||||||||||||||||||||||||||||||
| 38 | 2 | $self->obj_req( Net::OBEX::Packet::Request->new ); | |||||||||||||||||||||||||||||||||||||||||
| 39 | 2 | $self->obj_res( Net::OBEX::Response->new ); | |||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | 2 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||||||||||||
| 44 | 0 | ▶ | sub connect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
connect: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 45 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 46 | 0 | $self->$_(undef) for qw(success code status mtu); | |||||||||||||||||||||||||||||||||||||||||
| 47 | 0 | ▶ | get_args_as_hash(\@_, \ my %args, { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 48 | version => "\x10", | ||||||||||||||||||||||||||||||||||||||||||
| 49 | mtu => 4096, | ||||||||||||||||||||||||||||||||||||||||||
| 50 | domain => 'bluetooth', | ||||||||||||||||||||||||||||||||||||||||||
| 51 | type => 'stream', | ||||||||||||||||||||||||||||||||||||||||||
| 52 | proto => 'rfcomm', | ||||||||||||||||||||||||||||||||||||||||||
| 53 | headers => [], | ||||||||||||||||||||||||||||||||||||||||||
| 54 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | [ qw(address port) ], | ||||||||||||||||||||||||||||||||||||||||||
| 56 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 57 | or croak $@; | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | my $sock = Socket::Class->new( | ||||||||||||||||||||||||||||||||||||||||||
| 60 | 'domain' => $args{domain}, | ||||||||||||||||||||||||||||||||||||||||||
| 61 | 'type' => $args{type}, | ||||||||||||||||||||||||||||||||||||||||||
| 62 | 'proto' => $args{proto}, | ||||||||||||||||||||||||||||||||||||||||||
| 63 | 'remote_addr' => $args{address}, | ||||||||||||||||||||||||||||||||||||||||||
| 64 | 'remote_port' => $args{port}, | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 0 | ▶ | ) or return $self->_set_error( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 'Failed to create socket: ' . Socket::Class->error | ||||||||||||||||||||||||||||||||||||||||||
| 67 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | 0 | $self->sock( $sock ); | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | defined $args{target} | ||||||||||||||||||||||||||||||||||||||||||
| 72 | 0 | and push @{ $args{headers} }, | |||||||||||||||||||||||||||||||||||||||||
| 73 | 0 | ▶ | $self->obj_head->make( target => pack 'H*', $args{target} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | my $connect_packet = $self->obj_req->make( | ||||||||||||||||||||||||||||||||||||||||||
| 76 | packet => 'connect', | ||||||||||||||||||||||||||||||||||||||||||
| 77 | mtu => $args{mtu}, | ||||||||||||||||||||||||||||||||||||||||||
| 78 | version => $args{version}, | ||||||||||||||||||||||||||||||||||||||||||
| 79 | headers => $args{headers}, | ||||||||||||||||||||||||||||||||||||||||||
| 80 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 81 | 0 | $sock->send( $connect_packet ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my $obj_response = $self->obj_res; | |||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | ▶ | my $response_ref = $obj_response->parse_sock( $sock, 'connect' ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | or return $self->_set_error( $obj_response->error ); | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | # make and save connection ID header.. we will need it in every | ||||||||||||||||||||||||||||||||||||||||||
| 88 | # packet | ||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | ▶ | if ( defined (my $id = $response_ref->{headers}{connection_id}) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $self->connection_id( | |||||||||||||||||||||||||||||||||||||||||
| 91 | $self->obj_head->make( connection_id => $id ) | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | # save other party's MTU | ||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | ▶ | $self->mtu( $response_ref->{info}{mtu} || 255 ); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$response_ref->{'info'}{'mtu'} || 255
MC/DC0%0/1
$response_ref->{'info'}{'mtu'} || 255
$response_ref->{'info'}{'mtu'}
Truth table0%0/2
A
A= $response_ref->{'info'}{'mtu'}
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | ▶ | $response_ref->{info}{response_code} == 200 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 99 | and $self->success(1); | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->code( $response_ref->{info}{response_code} ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | $self->status( $response_ref->{info}{response_code_meaning} ); | |||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | return $self->response( $response_ref ); | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | sub disconnect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
disconnect: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | get_args_as_hash( \@_, \ my %args, { headers => [] } ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | or croak $@; | ||||||||||||||||||||||||||||||||||||||||||
| 111 | |||||||||||||||||||||||||||||||||||||||||||
| 112 | # Connection ID must be the first header if it's present | ||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | $self->_add_connection_id( $args{headers} ); | |||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | defined $args{description} | ||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | and push @{ $args{headers} }, | |||||||||||||||||||||||||||||||||||||||||
| 117 | 0 | ▶ | $self->head->make( description => $args{description} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||||||||||||
| 119 | my $disconnect_packet = $self->obj_req->make( | ||||||||||||||||||||||||||||||||||||||||||
| 120 | packet => 'disconnect', | ||||||||||||||||||||||||||||||||||||||||||
| 121 | headers => $args{headers}, | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | my $sock = $self->sock; | |||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | $sock->send( $disconnect_packet ); | |||||||||||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | my $obj_response = $self->obj_res; | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | my $response_ref = $obj_response->parse_sock( $sock ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | or return $self->_set_error( $obj_response->error ); | ||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | return $self->response( $response_ref ); | |||||||||||||||||||||||||||||||||||||||||
| 132 | } | ||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | sub set_path { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_path: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $self->$_(undef) for qw(success code status); | |||||||||||||||||||||||||||||||||||||||||
| 137 | 0 | ▶ | get_args_as_hash( \@_, \ my %args, { headers => [] } ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | or croak $@; | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | # Connection ID must be the first header if it's present | ||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $self->_add_connection_id( $args{headers} ); | |||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||
| 143 | # the path to setpath to should go into Name header | ||||||||||||||||||||||||||||||||||||||||||
| 144 | defined $args{path} | ||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | and push @{ $args{headers} }, | |||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | $self->obj_head->make( name => $args{path} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | my $set_path_packet = $self->obj_req->make( | ||||||||||||||||||||||||||||||||||||||||||
| 149 | packet => 'setpath', | ||||||||||||||||||||||||||||||||||||||||||
| 150 | headers => $args{headers}, | ||||||||||||||||||||||||||||||||||||||||||
| 151 | (defined $args{do_up } ? ( do_up => $args{do_up } ) : ()), | ||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | ▶ | (defined $args{no_create} ? ( no_create => $args{no_create} ) : ()), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | my $sock = $self->sock; | |||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $sock->send( $set_path_packet ); | |||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | my $obj_response = $self->obj_res; | |||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | my $response_ref = $obj_response->parse_sock( $sock ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 160 | or return $self->_set_error( $obj_response->error ); | ||||||||||||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | ▶ | $response_ref->{info}{response_code} == 200 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 163 | and $self->success(1); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | 0 | $self->code( $response_ref->{info}{response_code} ); | |||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | $self->status( $response_ref->{info}{response_code_meaning} ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | return $self->response( $response_ref ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | } | ||||||||||||||||||||||||||||||||||||||||||
| 170 | |||||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | sub get { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get: not called CC=17 SCAR=57.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $self->$_(undef) for qw(success code status); | |||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | ▶ | get_args_as_hash( \@_, \ my %args, { is_final => 1, headers => [] } ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 175 | or croak $@; | ||||||||||||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||||||||||||
| 177 | # Connection ID must be the first header if it's present | ||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $self->_add_connection_id( $args{headers} ); | |||||||||||||||||||||||||||||||||||||||||
| 179 | |||||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | my $head = $self->obj_head; | |||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | for ( qw(type name ) ) { | |||||||||||||||||||||||||||||||||||||||||
| 182 | defined $args{ $_ } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | 0 | ▶ | and push @{ $args{headers} }, $head->make( $_ => $args{ $_ } ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | my $obj_request = $self->obj_req; | |||||||||||||||||||||||||||||||||||||||||
| 187 | my $packet = $obj_request->make( | ||||||||||||||||||||||||||||||||||||||||||
| 188 | packet => 'get', | ||||||||||||||||||||||||||||||||||||||||||
| 189 | is_final => $args{is_final}, | ||||||||||||||||||||||||||||||||||||||||||
| 190 | headers => $args{headers}, | ||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my $sock = $self->sock; | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | $sock->send( $packet ); | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | my @responses; | |||||||||||||||||||||||||||||||||||||||||
| 197 | 0 | my $obj_response = $self->obj_res; | |||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | my $full_body = ''; | |||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $first_response_code; | |||||||||||||||||||||||||||||||||||||||||
| 200 | my $first_response_code_meaning; | ||||||||||||||||||||||||||||||||||||||||||
| 201 | CONTINIUE_GET: { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | ▶ | my $response_ref = $obj_response->parse_sock( $sock ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | or return $self->_set_error( $obj_response->error ); | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | unless ( defined $first_response_code ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | ( $first_response_code, $first_response_code_meaning ) | ||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | = @{ $response_ref->{info} }{ | |||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | qw(response_code response_code_meaning) | |||||||||||||||||||||||||||||||||||||||||
| 209 | } | ||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | ▶ | if ( exists $response_ref->{headers}{body} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
exists $response_ref->{"headers"}{"body"} or exists $response_ref->{"headers"}{"end_of_body"}
MC/DC0%0/2
exists $response_ref->{"headers"}{"body"} or exists $response_ref->{"headers"}{"end_of_body"}
exists $response_ref->{"headers"}{"body"}
exists $response_ref->{"headers"}{"end_of_body"}
Truth table0%0/3
A or B
A= exists $response_ref->{"headers"}{"body"}B= exists $response_ref->{"headers"}{"end_of_body"}
| |||||||||||||||||||||||||||||||||||||||||||
| 213 | or exists $response_ref->{headers}{end_of_body} | ||||||||||||||||||||||||||||||||||||||||||
| 214 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 215 | my $body = exists $response_ref->{headers}{end_of_body} | ||||||||||||||||||||||||||||||||||||||||||
| 216 | ? $response_ref->{headers}{end_of_body} | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | ▶ | : $response_ref->{headers}{body}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | ▶ | if ( exists $args{file} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 220 | 0 | $args{file}->print($body); | |||||||||||||||||||||||||||||||||||||||||
| 221 | } | ||||||||||||||||||||||||||||||||||||||||||
| 222 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $full_body .= $body; | |||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | push @responses, $response_ref; | |||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||
| 228 | # if server asks to "Continue" | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 0 | ▶ | if ( $response_ref->{info}{response_code} == 100 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$response_ref->{"info"}{"response_code"} == 100 and not $args{"no_continue"}
MC/DC0%0/2
$response_ref->{"info"}{"response_code"} == 100 and not $args{"no_continue"}
$response_ref->{"info"}{"response_code"} == 100
not $args{"no_continue"}
Truth table0%0/3
A and not(B)
A= $response_ref->{"info"}{"response_code"} == 100B= not $args{"no_continue"}
| |||||||||||||||||||||||||||||||||||||||||||
| 230 | and not $args{no_continue} | ||||||||||||||||||||||||||||||||||||||||||
| 231 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | $sock->send( | |||||||||||||||||||||||||||||||||||||||||
| 233 | $obj_request->make( packet => 'get', is_final => 1 ) | ||||||||||||||||||||||||||||||||||||||||||
| 234 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | redo CONTINIUE_GET; | |||||||||||||||||||||||||||||||||||||||||
| 237 | } | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$response_ref->{"info"}{"response_code"} == 200 or $response_ref->{"info"}{"response_code"} == 100
MC/DC0%0/2
$response_ref->{"info"}{"response_code"} == 200 or $response_ref->{"info"}{"response_code"} == 100
$response_ref->{"info"}{"response_code"} == 200
$response_ref->{"info"}{"response_code"} == 100
Truth table0%0/3
A or B
A= $response_ref->{"info"}{"response_code"} == 200B= $response_ref->{"info"}{"response_code"} == 100
| |||||||||||||||||||||||||||||||||||||||||||
| 240 | $response_ref->{info}{response_code} == 200 | ||||||||||||||||||||||||||||||||||||||||||
| 241 | or $response_ref->{info}{response_code} == 100 | ||||||||||||||||||||||||||||||||||||||||||
| 242 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 243 | $self->status( | ||||||||||||||||||||||||||||||||||||||||||
| 244 | $response_ref->{info}{response_code_meaning} | ||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $self->code( $response_ref->{info}{response_code} ); | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $response_ref->{is_error} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | return $response_ref; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | } # CONTINUTE_GET block end | ||||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $first_response_code == 200 or $first_response_code == 100 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$first_response_code == 200 || $first_response_code == 100 && $self->success(1)
$first_response_code == 100 and $self->success(1)
MC/DC0%0/3
$first_response_code == 200 || $first_response_code == 100 && $self->success(1)
$first_response_code == 200
$first_response_code == 100
$self->success(1)
Truth table0%0/4
A || B and C
A= $first_response_code == 200B= $first_response_code == 100C= $self->success(1)
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | and $self->success(1); | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | $self->code( $first_response_code ); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $self->status( $first_response_code_meaning ); | |||||||||||||||||||||||||||||||||||||||||
| 257 | |||||||||||||||||||||||||||||||||||||||||||
| 258 | 0 | return $self->response( { | |||||||||||||||||||||||||||||||||||||||||
| 259 | body => $full_body, | ||||||||||||||||||||||||||||||||||||||||||
| 260 | responses => \@responses, | ||||||||||||||||||||||||||||||||||||||||||
| 261 | response_code => $first_response_code, | ||||||||||||||||||||||||||||||||||||||||||
| 262 | response_code_meaning => $first_response_code_meaning, | ||||||||||||||||||||||||||||||||||||||||||
| 263 | } | ||||||||||||||||||||||||||||||||||||||||||
| 264 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | ▶ | sub put { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put: not called CC=18 SCAR=58.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | $self->$_(undef) for qw(success code status); | |||||||||||||||||||||||||||||||||||||||||
| 270 | 0 | ▶ | get_args_as_hash( \@_, \ my %args, { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 271 | headers => [], | ||||||||||||||||||||||||||||||||||||||||||
| 272 | body_in_first => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 273 | no_name => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 274 | }, | ||||||||||||||||||||||||||||||||||||||||||
| 275 | [ 'what' ], | ||||||||||||||||||||||||||||||||||||||||||
| 276 | ) or croak $@; | ||||||||||||||||||||||||||||||||||||||||||
| 277 | |||||||||||||||||||||||||||||||||||||||||||
| 278 | # Connection ID must be the first header if it's present | ||||||||||||||||||||||||||||||||||||||||||
| 279 | 0 | $self->_add_connection_id( $args{headers} ); | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 0 | my $head = $self->obj_head; | |||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | for ( qw(length time name type) ) { | |||||||||||||||||||||||||||||||||||||||||
| 283 | exists $args{ $_ } | ||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | and push @{ $args{headers} }, $head->make( $_, $args{$_} ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | } | ||||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | unless ( $args{no_name} or exists $args{name} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$args{"no_name"} or exists $args{"name"}
MC/DC0%0/2
$args{"no_name"} or exists $args{"name"}
$args{"no_name"}
exists $args{"name"}
Truth table0%0/3
A or B
A= $args{"no_name"}B= exists $args{"name"}
| |||||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | push @{ $args{headers} }, $head->make( name => $args{what} ); | |||||||||||||||||||||||||||||||||||||||||
| 289 | } | ||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||
| 291 | open my $fh, '<', $args{what} | ||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | ▶ | or return $self->_set_error("Failed to open $args{what} ($!)"); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | binmode $fh; | |||||||||||||||||||||||||||||||||||||||||
| 295 | |||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | my $mtu = $self->mtu - 2 - length join '', @{ $args{headers} }; | |||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $sock = $self->sock; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $obj_res = $self->obj_res; | |||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $obj_req = $self->obj_req; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | unless ( $args{body_in_first} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | my $packet = $obj_req->make( | ||||||||||||||||||||||||||||||||||||||||||
| 303 | packet => 'put', | ||||||||||||||||||||||||||||||||||||||||||
| 304 | headers => $args{headers}, | ||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | $sock->send( $packet ); | |||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | my $response_ref = $obj_res->parse_sock( $sock ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | or return $self->_set_error( | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 'Socket error: ' . $obj_res->error | ||||||||||||||||||||||||||||||||||||||||||
| 311 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$response_ref->{"info"}{"response_code"} == 200 or $response_ref->{"info"}{"response_code"} == 100
MC/DC0%0/2
$response_ref->{"info"}{"response_code"} == 200 or $response_ref->{"info"}{"response_code"} == 100
$response_ref->{"info"}{"response_code"} == 200
$response_ref->{"info"}{"response_code"} == 100
Truth table0%0/3
A or B
A= $response_ref->{"info"}{"response_code"} == 200B= $response_ref->{"info"}{"response_code"} == 100
| |||||||||||||||||||||||||||||||||||||||||||
| 314 | $response_ref->{info}{response_code} == 200 | ||||||||||||||||||||||||||||||||||||||||||
| 315 | or $response_ref->{info}{response_code} == 100 | ||||||||||||||||||||||||||||||||||||||||||
| 316 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 317 | $self->status( | ||||||||||||||||||||||||||||||||||||||||||
| 318 | $response_ref->{info}{response_code_meaning} | ||||||||||||||||||||||||||||||||||||||||||
| 319 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 320 | 0 | $self->code( $response_ref->{info}{response_code} ); | |||||||||||||||||||||||||||||||||||||||||
| 321 | 0 | return $response_ref; | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | } | ||||||||||||||||||||||||||||||||||||||||||
| 324 | |||||||||||||||||||||||||||||||||||||||||||
| 325 | { | ||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | local $/ = \$mtu; | |||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | while ( <$fh> ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | my $packet = $obj_req->make( | ||||||||||||||||||||||||||||||||||||||||||
| 330 | packet => 'put', | ||||||||||||||||||||||||||||||||||||||||||
| 331 | headers => [ | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | ▶ | ( $args{body_in_first} ? () : @{ $args{headers} } ), | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 333 | $head->make( body => $_ ), | ||||||||||||||||||||||||||||||||||||||||||
| 334 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 335 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 0 | $sock->send( $packet ); | |||||||||||||||||||||||||||||||||||||||||
| 337 | 0 | ▶ | my $response_ref = $obj_res->parse_sock( $sock ) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 338 | or return $self->_set_error( | ||||||||||||||||||||||||||||||||||||||||||
| 339 | 'Socket error: ' . $obj_res->error | ||||||||||||||||||||||||||||||||||||||||||
| 340 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | unless ( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$response_ref->{"info"}{"response_code"} == 200 or $response_ref->{"info"}{"response_code"} == 100
MC/DC0%0/2
$response_ref->{"info"}{"response_code"} == 200 or $response_ref->{"info"}{"response_code"} == 100
$response_ref->{"info"}{"response_code"} == 200
$response_ref->{"info"}{"response_code"} == 100
Truth table0%0/3
A or B
A= $response_ref->{"info"}{"response_code"} == 200B= $response_ref->{"info"}{"response_code"} == 100
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | $response_ref->{info}{response_code} == 200 | ||||||||||||||||||||||||||||||||||||||||||
| 344 | or $response_ref->{info}{response_code} == 100 | ||||||||||||||||||||||||||||||||||||||||||
| 345 | ) { | ||||||||||||||||||||||||||||||||||||||||||
| 346 | $self->status( | ||||||||||||||||||||||||||||||||||||||||||
| 347 | $response_ref->{info}{response_code_meaning} | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ); | |||||||||||||||||||||||||||||||||||||||||
| 349 | 0 | $self->code( $response_ref->{info}{response_code} ); | |||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | $response_ref->{is_error} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | return $response_ref; | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||
| 354 | my $packet = $obj_req->make( | ||||||||||||||||||||||||||||||||||||||||||
| 355 | packet => 'put', | ||||||||||||||||||||||||||||||||||||||||||
| 356 | is_final => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 357 | headers => [ | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | @{ $args{headers} }, | |||||||||||||||||||||||||||||||||||||||||
| 359 | $head->make( end_of_body => '' ), | ||||||||||||||||||||||||||||||||||||||||||
| 360 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 361 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||
| 363 | 0 | $sock->send( $packet ); | |||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | my $response_ref = $obj_res->parse_sock( $sock ); | |||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | $response_ref->{info}{response_code} == 200 | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 366 | and $self->success(1); | ||||||||||||||||||||||||||||||||||||||||||
| 367 | |||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $self->code( $response_ref->{info}{response_code} ); | |||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $self->status( $response_ref->{info}{response_code_meaning} ); | |||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | return $self->response( $response_ref ); | |||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||
| 372 | } | ||||||||||||||||||||||||||||||||||||||||||
| 373 | |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | my ( $self, $description ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 376 | |||||||||||||||||||||||||||||||||||||||||||
| 377 | 0 | my $sock = $self->sock; | |||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | eval { | |||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | ▶ | my $disconnect_packet = $self->obj_req->make( | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | packet => 'disconnect', | ||||||||||||||||||||||||||||||||||||||||||
| 381 | headers => [ | ||||||||||||||||||||||||||||||||||||||||||
| 382 | defined $description | ||||||||||||||||||||||||||||||||||||||||||
| 383 | ? $self->obj_head->make( description => $description ) | ||||||||||||||||||||||||||||||||||||||||||
| 384 | : () | ||||||||||||||||||||||||||||||||||||||||||
| 385 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 386 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | $sock->send( $disconnect_packet ); | |||||||||||||||||||||||||||||||||||||||||
| 389 | }; | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | $sock->free(); | |||||||||||||||||||||||||||||||||||||||||
| 391 | |||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 393 | } | ||||||||||||||||||||||||||||||||||||||||||
| 394 | |||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | sub _add_connection_id { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_add_connection_id: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | my ( $self, $headers_ref ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | ▶ | if ( defined ( my $id = $self->connection_id ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | unshift @$headers_ref, $id; | |||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | } | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | sub _set_error { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_set_error: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my ( $self, $error ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $self->error( $error ); | |||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 406 | } | ||||||||||||||||||||||||||||||||||||||||||
| 407 | |||||||||||||||||||||||||||||||||||||||||||
| 408 | 4 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 409 | __END__ | ||||||||||||||||||||||||||||||||||||||||||