protected function getHeaders($response, &$request_line = null)
    {
        $parts = explode("\r\n\r\n", $response, 2);

        if (count($parts) < 2) {
            $parts[] = '';
        }

        list($headers, $body) = $parts;

        $return = [];
        foreach (explode("\r\n", $headers) as $header) {
            $parts = explode(': ', $header, 2);
            if (count($parts) == 2) {
                list($name, $value) = $parts;
                if (!isset($return[$name])) {
                    $return[$name] = $value;
                } else {
                    if (is_array($return[$name])) {
                        $return[$name][] = $value;
                    } else {
                        $return[$name] = [$return[$name], $value];
                    }
                }
            }
        }

        return array_change_key_case($return);
    }