note 128123 added to function.getallheaders
| From: | divinity76 at gmail dot com | Date: | Wed, 18 Jan 2023 14:21:48 +0000 |
| Subject: | note 128123 added to function.getallheaders | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-220078@lists.php.net to get a copy of this message | ||
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) === "") {
// probably a getallheaders() bug, not actual request headers.
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
----
Server IP: 45.112.84.4
Probable Submitter: 45.91.158.213 (proxied: 62.101.231.203)
----
Manual Page -- https://php.net/manual/en/function.getallheaders.php
Edit -- https://main.php.net/note/edit/128123
Del: integrated -- https://main.php.net/note/delete/128123/integrated
Del: useless -- https://main.php.net/note/delete/128123/useless
Del: bad code -- https://main.php.net/note/delete/128123/bad+code
Del: spam -- https://main.php.net/note/delete/128123/spam
Del: non-english -- https://main.php.net/note/delete/128123/non-english
Del: in docs -- https://main.php.net/note/delete/128123/in+docs
Del: other reasons-- https://main.php.net/note/delete/128123
Reject -- https://main.php.net/note/reject/128123
Search -- https://main.php.net/manage/user-notes.php