warning, at least on php-fpm 8.2.1 and nginx, getallheaders() will return "Content-Length" and "Content-Type" both containing emptystring, even for requests without any of these 2 headers. you can do something like
<?php
$request_headers = getallheaders();
if(($request_headers["Content-Type"] ?? null) === "" && ($request_headers["Content-Length"] ?? null) === "") {
unset($request_headers["Content-Type"], $request_headers["Content-Length"]);
}
?>
- might be a bug in nginx rather than php-fpm, i don't know. anyway a real request wouldn't leave them at emptystring