]> git.proxmox.com Git - pve-http-server.git/commitdiff
proxy request: handle missing content-type header
authorStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 9 Jun 2023 16:11:45 +0000 (18:11 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Fri, 9 Jun 2023 16:57:28 +0000 (18:57 +0200)
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 f398a3d94bb5c798e1e1ea91113cd76648dd79eb

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>
src/PVE/APIServer/AnyEvent.pm

index 6831a8656290bfd1fcfe1b92cd8970a30bedfc2b..1fd7a74ed9b0b176cf9c713b9adc8d20b02d4ef7 100644 (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 {