@@ -29,17 +29,38 @@ sub _build__url_base {
29
29
}
30
30
31
31
sub _prep_url {
32
- my ($self , $path , %args ) = @_ ;
32
+ my ($self , $method , $ path , %args ) = @_ ;
33
33
my $trailing = $path =~ m { /$} ;
34
34
my $url = $self -> _url_base.join (' /' , map { uri_escape($_ ) } split (' /' , $path ));
35
35
$url .= ' /' if $trailing ;
36
+ delete ($args {value }) if (uc ($method ) eq ' PUT' );
36
37
$url .= ' ?' .$self -> http-> www_form_urlencode(\%args ) if %args ;
37
38
$url ;
38
39
}
39
40
40
41
sub api_exec {
41
42
my ($self , $path , $method , %args ) = @_ ;
42
- my $res = $self -> http-> request($method , $self -> _prep_url($path , %args ));
43
+
44
+ my $urlencoded ;
45
+
46
+ $urlencoded = $self -> http-> www_form_urlencode({ value => $args {value } })
47
+ if (uc ($method ) eq ' PUT' );
48
+
49
+ my $res = $self -> http-> request(
50
+ $method ,
51
+ $self -> _prep_url($method , $path , %args ),
52
+ (uc ($method ) eq ' PUT' ?
53
+ {
54
+ headers => {
55
+ ' content-length' => length ($urlencoded ),
56
+ ' content-type' => ' application/x-www-form-urlencoded' ,
57
+ ' expect' => ' 100-continue' ,
58
+ },
59
+ content => $urlencoded
60
+ } :
61
+ undef )
62
+ );
63
+
43
64
$res = $self -> http-> request($method , $res -> {headers }-> {location })
44
65
if $res && $res -> {status } eq 307;
45
66
return $res if $res -> {success };
0 commit comments