public function proxy($event): LambdaResponse
    {
        if (! isset($event['httpMethod'])) {
            throw new \Exception('The lambda was not invoked via HTTP through API Gateway: this is not supported by this runtime');
        }

        $request = $this->eventToFastCgiRequest($event);

        try {
            $response = $this->client->sendRequest($request);
        } catch (\Throwable $e) {
            throw new FastCgiCommunicationFailed(sprintf(
                'Error communicating with PHP-FPM to read the HTTP response. A root cause of this can be that the Lambda (or PHP) timed out, for example when trying to connect to a remote API or database, if this happens continuously check for those! Original exception message: %s %s',
                get_class($e),
                $e->getMessage()
            ), 0, $e);
        }

        $responseHeaders = $response->getHeaders();
        $responseHeaders = array_change_key_case($responseHeaders, CASE_LOWER);

        // Extract the status code
        if (isset($responseHeaders['status'])) {
            [$status] = explode(' ', $responseHeaders['status']);
        } else {
            $status = 200;
        }
        unset($responseHeaders['status']);

        return new LambdaResponse((int) $status, $responseHeaders, $response->getBody());
    }