proxy request: handle missing content-type header

In case the actual request-body is empty it seems not Content-Type
header is set by browsers.

Tested on a vm with stopping and starting a container via GUI
(/api2/extjs/nodes/<nodename>/lxc/<vmid>/status/stop)

fixes f398a3d94b

Reported-by: Friedrich Weber <f.weber@proxmox.com>
Reported-by: Fiona Ebner <f.ebner@proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
This commit is contained in:
Stoiko Ivanov 2023-06-09 18:11:45 +02:00 committed by Thomas Lamprecht
parent 0e761983b9
commit 81f0f40ea1

View File

@ -745,7 +745,8 @@ sub proxy_request {
my $content;
if ($method eq 'POST' || $method eq 'PUT') {
if ($reqstate->{request}->header('Content-Type') =~ 'application/json') {
my $request_ct = $reqstate->{request}->header('Content-Type');
if (defined($request_ct) && $request_ct =~ 'application/json') {
$headers->{'Content-Type'} = 'application/json';
$content = encode_json($params);
} else {