From dde4dfb972b5b55b8c2f1b953177530a0c86a912 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Wed, 4 Sep 2013 14:31:23 +0200 Subject: [PATCH] add correct parameters to PUT requests --- PVE/API2Client.pm | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/PVE/API2Client.pm b/PVE/API2Client.pm index c573050b..1e65058e 100755 --- a/PVE/API2Client.pm +++ b/PVE/API2Client.pm @@ -98,7 +98,15 @@ sub call { } elsif ($method eq 'POST') { $response = $ua->request(HTTP::Request::Common::POST($uri, Content => $param)); } elsif ($method eq 'PUT') { - $response = $ua->request(HTTP::Request::Common::PUT($uri, Content => $param)); + # We use another temporary URI object to format + # the application/x-www-form-urlencoded content. + + my $tmpurl = URI->new('http:'); + $tmpurl->query_form(%$param); + my $content = $tmpurl->query; + + $response = $ua->request(HTTP::Request::Common::PUT($uri, 'Content-Type' => 'application/x-www-form-urlencoded', Content => $content)); + } elsif ($method eq 'DELETE') { $response = $ua->request(HTTP::Request::Common::DELETE($uri)); } else { @@ -107,7 +115,7 @@ sub call { #print "RESP: " . Dumper($response) . "\n"; - my $ct = $response->header('Content-Type'); + my $ct = $response->header('Content-Type') || ''; if ($response->is_success) {