| 1 | package Net::STF::Client; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use Net::STF::Bucket; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use Net::STF::Object; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 1 | ▶ | use Carp (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 1 | ▶ | use Furl::HTTP; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 1 | ▶ | use HTTP::Status (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use MIME::Base64 (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Scalar::Util (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use URI (); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 11 | use Class::Accessor::Lite | ||||||||||||||||||||||||||||||||||||||||||
| 12 | 1 | ▶ | rw => [ qw( | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 13 | furl | ||||||||||||||||||||||||||||||||||||||||||
| 14 | agent_name | ||||||||||||||||||||||||||||||||||||||||||
| 15 | repl_count | ||||||||||||||||||||||||||||||||||||||||||
| 16 | url | ||||||||||||||||||||||||||||||||||||||||||
| 17 | error | ||||||||||||||||||||||||||||||||||||||||||
| 18 | username | ||||||||||||||||||||||||||||||||||||||||||
| 19 | password | ||||||||||||||||||||||||||||||||||||||||||
| 20 | ) ] | ||||||||||||||||||||||||||||||||||||||||||
| 21 | 1 | ; | |||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | 1 | our $VERSION = '1.01'; | |||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | 1 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=7 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 26 | 1 | my $class = shift; | |||||||||||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||||||||||||
| 28 | # Grr, allow hashrefs | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 1 | ▶ | if (@_ == 1 && ref $_[0] eq 'HASH') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
@_ == 1 and ref $_[0] eq "HASH"
MC/DC0%0/2
@_ == 1 and ref $_[0] eq "HASH"
@_ == 1
ref $_[0] eq "HASH"
Truth table33%1/3
A and B
A= @_ == 1B= ref $_[0] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 0 | @_ = %{$_[0]}; | |||||||||||||||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | # Only exists to provide back compat with non-published version. | ||||||||||||||||||||||||||||||||||||||||||
| 34 | # You shouldn't be using this | ||||||||||||||||||||||||||||||||||||||||||
| 35 | 1 | ▶ | if ( @_ == 2 && ! ref $_[0] && ref $_[1] eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
@_ == 2 and not ref $_[0] and ref $_[1] eq "HASH"
@_ == 2 and not ref $_[0]
MC/DC0%0/3
@_ == 2 and not ref $_[0] and ref $_[1] eq "HASH"
@_ == 2
not ref $_[0]
ref $_[1] eq "HASH"
Truth table25%1/4
A and not(B) and C
A= @_ == 2B= not ref $_[0]C= ref $_[1] eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | # Net::STF style | ||||||||||||||||||||||||||||||||||||||||||
| 37 | 0 | @_ = ( url => $_[0], %{$_[1]} ); | |||||||||||||||||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 1 | my $self = bless { | |||||||||||||||||||||||||||||||||||||||||
| 41 | agent_name => join( '/', $class, $VERSION ), | ||||||||||||||||||||||||||||||||||||||||||
| 42 | repl_count => 3, | ||||||||||||||||||||||||||||||||||||||||||
| 43 | @_ | ||||||||||||||||||||||||||||||||||||||||||
| 44 | }, $class; | ||||||||||||||||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||||||||||||||||
| 46 | 1 | ▶ | if (! $self->furl ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 47 | 1 | $self->furl(Furl::HTTP->new( agent => $self->agent_name )); | |||||||||||||||||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | 1 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | 14 | ▶ | sub _url_is_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_url_is_object: called CC=2 SCAR=7.6
| |||||||||||||||||||||||||||||||||||||||||||
| 54 | # Make sure the URL contains more than one level in its path. | ||||||||||||||||||||||||||||||||||||||||||
| 55 | # Otherwise, you may end up getting stuff like | ||||||||||||||||||||||||||||||||||||||||||
| 56 | # DELETE http://stf.example.com/foo/ | ||||||||||||||||||||||||||||||||||||||||||
| 57 | # instead of | ||||||||||||||||||||||||||||||||||||||||||
| 58 | # DELETE http://stf.example.com/foo/bar | ||||||||||||||||||||||||||||||||||||||||||
| 59 | # The former deletes the BUCKET, whereas the latter deletes the object. | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | # XXX regex copied from URI.pm | ||||||||||||||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||||||||||||
| 63 | 14 | my (undef, undef, $path) = | |||||||||||||||||||||||||||||||||||||||||
| 64 | $_[0] =~ m|(?:([^:/?#]+):)?(?://([^/?#]*))?([^?#]*)(?:\?([^#]*))?(?:#(.*))?|; | ||||||||||||||||||||||||||||||||||||||||||
| 65 | 14 | ▶ | if ($path =~ m{^/+[^/]+(?:/+[\./]*)?$}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 66 | 14 | Carp::croak("Invalid object URL given -> $_[0]"); | |||||||||||||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||||||||||||
| 68 | 0 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 69 | } | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 14 | ▶ | sub _qualify_url { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_qualify_url: called CC=2 SCAR=7.4
| |||||||||||||||||||||||||||||||||||||||||||
| 72 | 14 | my ($self, $url) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 14 | my $prefix = $self->url; | |||||||||||||||||||||||||||||||||||||||||
| 75 | 14 | ▶ | if (! $prefix) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 76 | 14 | return $url; | |||||||||||||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | 0 | return URI->new($url)->abs($prefix)->canonical; | |||||||||||||||||||||||||||||||||||||||||
| 80 | } | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | sub get_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_object: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 83 | 0 | my ($self, $url, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $self->error(undef); | |||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $url = $self->_qualify_url($url); | |||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | my %furlopts = ( | |||||||||||||||||||||||||||||||||||||||||
| 90 | method => 'GET', | ||||||||||||||||||||||||||||||||||||||||||
| 91 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 92 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | my @res = $self->send_request( \%furlopts, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | if ( ! HTTP::Status::is_success( $res[1] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 95 | 0 | $self->error( $res[2] ); | |||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 97 | } | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | return Net::STF::Object->new( | |||||||||||||||||||||||||||||||||||||||||
| 99 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 100 | content => $res[4] | ||||||||||||||||||||||||||||||||||||||||||
| 101 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | 0 | ▶ | sub send_request { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
send_request: not called CC=7 SCAR=40.3
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my ($self, $furlopts, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | ▶ | $furlopts->{headers} ||= []; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$furlopts->{"headers"} ||= []
MC/DC0%0/1
$furlopts->{"headers"} ||= []
$furlopts->{"headers"}
Truth table0%0/2
A
A= $furlopts->{"headers"}
| |||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | my ($username, $password) = ( $self->username, $self->password ); | |||||||||||||||||||||||||||||||||||||||||
| 110 | 0 | ▶ | if (defined $username && defined $password ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $username and defined $password
MC/DC0%0/2
defined $username and defined $password
defined $username
defined $password
Truth table0%0/3
A and B
A= defined $usernameB= defined $password
| |||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | push @{ $furlopts->{headers} }, | |||||||||||||||||||||||||||||||||||||||||
| 112 | ( 'Authorization' => "Basic " . MIME::Base64::encode("$username:$password", "") ); | ||||||||||||||||||||||||||||||||||||||||||
| 113 | } | ||||||||||||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ( $opts->{headers} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | push @{$furlopts->{headers}}, @{$opts->{headers}}; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | foreach my $key ( qw(write_file write_code) ) { | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | if (my $value = $opts->{$key}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $furlopts->{$key} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | return $self->furl->request( %$furlopts ); | |||||||||||||||||||||||||||||||||||||||||
| 124 | } | ||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 7 | ▶ | sub put_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
put_object: called CC=9 SCAR=42.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | 7 | my ($self, $url, $content, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||
| 129 | 7 | $self->error(undef); | |||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||
| 131 | 7 | $url = $self->_qualify_url($url); | |||||||||||||||||||||||||||||||||||||||||
| 132 | 7 | _url_is_object($url); | |||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | ▶ | if (! defined $content ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | Carp::croak( "No content provided" ); | |||||||||||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if ( ref $content eq 'SCALAR' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | # raw string passed | ||||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | $content = $$content; | |||||||||||||||||||||||||||||||||||||||||
| 141 | } elsif ( Scalar::Util::openhandle( $content ) ) { | ||||||||||||||||||||||||||||||||||||||||||
| 142 | # make sure we're at the beginning of the file | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | seek $content, 0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 145 | # assume it's a file. | ||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | ▶ | open my $fh, '<', $content | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 147 | or die "Failed to open file $content: $!"; | ||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | $content = $fh; | |||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | seek $content, 0, 0; | |||||||||||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | my @hdrs; | |||||||||||||||||||||||||||||||||||||||||
| 153 | push @hdrs, | ||||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | ("X-STF-Replication-Count", ($opts->{repl_count} || $self->repl_count)); | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$opts->{'repl_count'} || $self->repl_count
MC/DC0%0/2
$opts->{'repl_count'} || $self->repl_count
$opts->{'repl_count'}
$self->repl_count
Truth table0%0/3
A || B
A= $opts->{'repl_count'}B= $self->repl_count
| |||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | ▶ | if (my $consistency = $opts->{consistency}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | push @hdrs, "X-STF-Consistency", $consistency; | |||||||||||||||||||||||||||||||||||||||||
| 157 | } | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my %furlopts = ( | |||||||||||||||||||||||||||||||||||||||||
| 161 | method => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||
| 162 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 163 | headers => \@hdrs, | ||||||||||||||||||||||||||||||||||||||||||
| 164 | content => $content, | ||||||||||||||||||||||||||||||||||||||||||
| 165 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my @res = $self->send_request( \%furlopts, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | ▶ | if (! HTTP::Status::is_success($res[1])) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 168 | 0 | $self->error( $res[2] ); | |||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 170 | } | ||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||
| 172 | # if you don't want a result, then we don't create an object | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | ▶ | return if !defined wantarray; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | |||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | return Net::STF::Object->new( | |||||||||||||||||||||||||||||||||||||||||
| 176 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 177 | # content => $res[4] | ||||||||||||||||||||||||||||||||||||||||||
| 178 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 179 | } | ||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||
| 181 | 7 | ▶ | sub delete_object { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_object: called CC=2 SCAR=11.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 7 | my ($self, $url, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||||||||||||
| 184 | 7 | $self->error(undef); | |||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 7 | $url = $self->_qualify_url($url); | |||||||||||||||||||||||||||||||||||||||||
| 187 | 7 | _url_is_object($url); | |||||||||||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | my %furlopts = ( | |||||||||||||||||||||||||||||||||||||||||
| 190 | method => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||
| 191 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 192 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | my @res = $self->send_request( \%furlopts, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 194 | 0 | ▶ | if ( ! HTTP::Status::is_success( $res[1] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 195 | 0 | $self->error( $res[2] ); | |||||||||||||||||||||||||||||||||||||||||
| 196 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 199 | } | ||||||||||||||||||||||||||||||||||||||||||
| 200 | |||||||||||||||||||||||||||||||||||||||||||
| 201 | 0 | ▶ | sub create_bucket { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
create_bucket: not called CC=2 SCAR=17.9
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 202 | 0 | my ($self, $url, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | 0 | $self->error(undef); | |||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | $url = $self->_qualify_url($url); | |||||||||||||||||||||||||||||||||||||||||
| 207 | |||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | my %furlopts = ( | |||||||||||||||||||||||||||||||||||||||||
| 209 | method => 'PUT', | ||||||||||||||||||||||||||||||||||||||||||
| 210 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 211 | headers => [ | ||||||||||||||||||||||||||||||||||||||||||
| 212 | 'Content-Length' => 0, | ||||||||||||||||||||||||||||||||||||||||||
| 213 | ], | ||||||||||||||||||||||||||||||||||||||||||
| 214 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | my @res = $self->send_request( \%furlopts, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | ▶ | if (! HTTP::Status::is_success( $res[1] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 217 | 0 | $self->error( $res[2] ); | |||||||||||||||||||||||||||||||||||||||||
| 218 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 219 | } | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | 0 | return Net::STF::Bucket->new( | |||||||||||||||||||||||||||||||||||||||||
| 222 | client => $self, | ||||||||||||||||||||||||||||||||||||||||||
| 223 | name => ( URI->new($url)->path =~ m{^/([^/]+)} )[0], | ||||||||||||||||||||||||||||||||||||||||||
| 224 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | 0 | ▶ | sub delete_bucket { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
delete_bucket: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 228 | 0 | my ($self, $url, $opts) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 229 | |||||||||||||||||||||||||||||||||||||||||||
| 230 | 0 | $self->error(undef); | |||||||||||||||||||||||||||||||||||||||||
| 231 | |||||||||||||||||||||||||||||||||||||||||||
| 232 | 0 | my @hdrs; | |||||||||||||||||||||||||||||||||||||||||
| 233 | 0 | ▶ | if ( $opts->{recursive} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | push @hdrs, "X-STF-Recursive-Delete" => "true"; | |||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | 0 | $url = $self->_qualify_url($url); | |||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | 0 | my %furlopts = ( | |||||||||||||||||||||||||||||||||||||||||
| 240 | method => 'DELETE', | ||||||||||||||||||||||||||||||||||||||||||
| 241 | headers => \@hdrs, | ||||||||||||||||||||||||||||||||||||||||||
| 242 | url => $url, | ||||||||||||||||||||||||||||||||||||||||||
| 243 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | my @res = $self->send_request( \%furlopts, $opts ); | |||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if (! HTTP::Status::is_success( $res[1] ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | $self->error( $res[2] ); | |||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | 1 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||||||||||||
| 256 | __END__ | ||||||||||||||||||||||||||||||||||||||||||