I am using getallheaders() php global function to get all the headers of the current request. In php manual for it says that it is a alias of the apache_request_headers and it becomes available in CLI server. what is meant by CLI server?
I am using getallheaders() php global function to get all the headers of the current request. In php manual for it says that it is a alias of the apache_request_headers and it becomes available in CLI server. what is meant by CLI server?
With the php's bug #66606, the php's built-in web server stores the Content-Type and Content-Length header values in HTTP_CONTENT_TYPE and HTTP_CONTENT_LENGTH fields.
You can get these values depending on the value of PHP_SAPI:
if ('cli-server' === PHP_SAPI) {
if (array_key_exists('HTTP_CONTENT_LENGTH', $_SERVER)) {
$content_length = $_SERVER['HTTP_CONTENT_LENGTH'];
}
if (array_key_exists('HTTP_CONTENT_TYPE', $_SERVER)) {
$contentType = $_SERVER['HTTP_CONTENT_TYPE'];
}
}