public static function prepareHeaders(ResponseInterface $response): array
    {
        $preparedHeaders = [];
        $statusHeader = rtrim(self::generateStatusLine($response), "\r\n");

        $preparedHeaders[] = $statusHeader;
        $headers = $response->getHeaders();
        if ($headers instanceof Headers) {
            $preparedHeaders = array_merge($preparedHeaders, $headers->getPreparedValues());
        } else {
            foreach (array_keys($headers) as $name) {
                $preparedHeaders[] = $response->getHeaderLine($name);
            }
        }

        return $preparedHeaders;
    }