private function loadHttpHeaders(): array
    {
        if (function_exists('getallheaders')) {
            $headers = getallheaders(); // apache
        } else {
            $headers = [];
            foreach ($_SERVER as $key => $value) {
                if (stripos(strval($key), 'HTTP_') === 0) {
                    $headers[
                        // normalize key
                        implode('-', array_map('ucwords', explode('_', strtolower(substr($key, 5)))))
                    ] = $value;
                }
            }
        }

        // content issues
        if (isset($_SERVER['CONTENT_TYPE'])) {
            $headers['Content-Type'] = $_SERVER['CONTENT_TYPE'];
        }
        if (isset($_SERVER['CONTENT_LENGTH'])) {
            $headers['Content-Length'] = $_SERVER['CONTENT_LENGTH'];
        }
        if (isset($_SERVER['CONTENT_MD5'])) {
            $headers['Content-MD5'] = $_SERVER['CONTENT_MD5'];
        }

        // authorization issues
        if (!isset($headers['Authorization'])) {
            if (isset($_SERVER['REDIRECT_HTTP_AUTHORIZATION'])) {
                $headers['Authorization'] = $_SERVER['REDIRECT_HTTP_AUTHORIZATION'];
            } elseif (isset($_SERVER['PHP_AUTH_DIGEST'])) {
                $headers['Authorization'] = $_SERVER['PHP_AUTH_DIGEST'];
            } elseif (isset($_SERVER['PHP_AUTH_USER'])) {
                $headers['Authorization'] = 'Basic ' .
                    base64_encode($_SERVER['PHP_AUTH_USER'] .':'. ($_SERVER['PHP_AUTH_PW'] ?? ''));
            }
        }

        return $headers;
    }