mirror of
https://git.proxmox.com/git/pve-http-server
synced 2025-05-28 07:07:28 +00:00
proxy request: forward json content type and parameters
instead of always trying to encode them as x-www-form-urlencoded Acked-by: Wolfgang Bumiller <w.bumiller@proxmox.com> Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
This commit is contained in:
parent
ded13125c2
commit
f398a3d94b
@ -745,11 +745,16 @@ sub proxy_request {
|
||||
my $content;
|
||||
|
||||
if ($method eq 'POST' || $method eq 'PUT') {
|
||||
$headers->{'Content-Type'} = 'application/x-www-form-urlencoded';
|
||||
# use URI object to format application/x-www-form-urlencoded content.
|
||||
my $url = URI->new('http:');
|
||||
$url->query_form(%$params);
|
||||
$content = $url->query;
|
||||
if ($reqstate->{request}->header('Content-Type') =~ 'application/json') {
|
||||
$headers->{'Content-Type'} = 'application/json';
|
||||
$content = encode_json($params);
|
||||
} else {
|
||||
$headers->{'Content-Type'} = 'application/x-www-form-urlencoded';
|
||||
# use URI object to format application/x-www-form-urlencoded content.
|
||||
my $url = URI->new('http:');
|
||||
$url->query_form(%$params);
|
||||
$content = $url->query;
|
||||
}
|
||||
if (defined($content)) {
|
||||
$headers->{'Content-Length'} = length($content);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user