[pve-devel] [PATCH http-server] proxy request: handle missing content-type header
Stoiko Ivanov
s.ivanov at proxmox.com
Fri Jun 9 18:11:45 CEST 2023
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 at proxmox.com>
Reported-by: Fiona Ebner <f.ebner at proxmox.com>
Signed-off-by: Stoiko Ivanov <s.ivanov at proxmox.com>
---
src/PVE/APIServer/AnyEvent.pm | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
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 {
--
2.30.2
More information about the pve-devel
mailing list