String parseToken(final CharSequence buf, final ParserCursor cursor) {
        final StringBuilder dst = new StringBuilder();
        while (!cursor.atEnd()) {
            int pos = cursor.getPos();
            char current = buf.charAt(pos);
            if (TERMINATORS.test(current)) {
                // Here it gets really ugly
                if (current == EQUAL_CHAR) {
                    // it can be a start of a parameter value or token68 padding
                    // Look ahead and see if there are more '=' or at end of buffer
                    if (pos + 1 < cursor.getUpperBound() && buf.charAt(pos + 1) != EQUAL_CHAR) {
                        break;
                    }
                    do {
                        dst.append(current);
                        pos++;
                        cursor.updatePos(pos);
                        if (cursor.atEnd()) {
                            break;
                        }
                        current = buf.charAt(pos);
                    } while (current == EQUAL_CHAR);
                } else {
                    break;
                }
            } else {
                dst.append(current);
                cursor.updatePos(pos + 1);
            }
        }
        return dst.toString();
    }
Parses the given sequence of characters into a list of {@link AuthChallenge} elements.

@param challengeType the type of challenge (target or proxy).
@param buffer the sequence of characters to be parsed.
@param cursor the parser cursor.
@return a list of auth challenge elements.
httpclient5/src/main/java/org/apache/hc/client5/http/impl/auth/AuthChallengeParser.java