Jump to content

ERROR: Call to undefined function getallheaders()


bernhard
 Share

Recommended Posts

Anybody of you ever came across this error? Seems to be a problem of PHP FPM: https://github.com/php/php-src/pull/3363

What is my alternative? @adrian we use this method in the tracy request logger, so this might need to be changed!

Edit:

if (!function_exists('getallheaders')) {
    function getallheaders() {
    $headers = [];
    foreach ($_SERVER as $name => $value) {
        if (substr($name, 0, 5) == 'HTTP_') {
            $headers[str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', substr($name, 5)))))] = $value;
        }
    }
    return $headers;
    }
}

This seems to fix it. If anybody has a better solution please let me know.

  • Like 1
Link to comment
Share on other sites

Hey @bernhard - I have a slightly revised version that tweaks the returned array to exactly match getallheaders().

I'll implement this is Tracy shortly unless anyone else has any better ideas.

 

$headers = [];
foreach($_SERVER as $name => $value) {
    if($name != 'HTTP_MOD_REWRITE' && (substr($name, 0, 5) == 'HTTP_' || $name == 'CONTENT_LENGTH' || $name == 'CONTENT_TYPE')) {
        $name = str_replace(' ', '-', ucwords(strtolower(str_replace('_', ' ', str_replace('HTTP_', '', $name)))));
        if($name == 'Content-Type') $name = 'Content-type';
        $headers[$name] = $value;
    }
}

image.thumb.png.b5da00fde5221299641ba7c5ed2939ba.png

  • Thanks 1
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...