private static function prepareHeaders(HeaderBag $headerBag)
    {
        $headers = $headerBag->all();
        $result = [];

        foreach ($headers as $header => $values) {
            $result[$header] = $values[0];
        }

        return $result;
    }