private function formatHeaders($response)
    {
        $headers = [];
        foreach ($response->getHeaders() as $name => $value) {
            $headers[strtolower($name)] = \is_array($value) ? implode(', ', $value) : $value;
        }

        return $headers;
    }