protected function findStatusInHeaders($headers)
    {
        if (!isset($headers[0]) || strpos($headers[0], 'HTTP/') !== 0) {
            throw new UnexpectedValueException('Invalid HTTP Headers, missing status line');
        }

        $parts = explode(' ', trim($headers[0]));

        return (int)trim($parts[1]);
    }