From: Stoiko Ivanov Date: Fri, 9 Jun 2023 16:11:45 +0000 (+0200) Subject: proxy request: handle missing content-type header X-Git-Url: https://git.proxmox.com/?p=pve-http-server.git;a=commitdiff_plain;h=81f0f40ea19bdda9c4983567f2b33d75c9aca588 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//lxc//status/stop) fixes f398a3d94bb5c798e1e1ea91113cd76648dd79eb Reported-by: Friedrich Weber Reported-by: Fiona Ebner Signed-off-by: Stoiko Ivanov --- diff --git a/src/PVE/APIServer/AnyEvent.pm b/src/PVE/APIServer/AnyEvent.pm index 6831a86..1fd7a74 100644 --- a/src/PVE/APIServer/AnyEvent.pm +++ b/src/PVE/APIServer/AnyEvent.pm @@ -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 {