public function createServerRequestFromArray(?array $server)
  {
    global $app;

    # Copied from Guzzles ::fromGlobals(), but we need to support the $server array as
    # paramter, so we use that instead of the $_SERVER array guzzle uses by default

    $method = isset($server['REQUEST_METHOD']) ? $server['REQUEST_METHOD'] : 'GET';
    $headers = \function_exists('getallheaders') ? \getallheaders() : [];
    $uri = ServerRequest::getUriFromGlobals();
    $body = new LazyOpenStream('php://input', 'r+');
    $protocol = isset($server['SERVER_PROTOCOL']) ? \str_replace('HTTP/', '', $server['SERVER_PROTOCOL']) : '1.1';

    $serverRequest = new ServerRequest($method, $uri, $headers, $body, $protocol, $server);

    \logger()->debug('Created PSR-7 ServerRequest("'.$method.'","'.$uri.'") from array (Guzzle)');

    return $serverRequest
           ->withCookieParams($_COOKIE)
           ->withQueryParams($_GET)
           ->withParsedBody($_POST)
           ->withUploadedFiles(ServerRequest::normalizeFiles($_FILES));
  }