private static void addRange(
            List<MediaType> ranges, CharSequence header, int firstCharIdx, int lastCharIdx) {
        if (lastCharIdx >= 0) {
            try {
                ranges.add(MediaType.parse(header.subSequence(firstCharIdx, lastCharIdx + 1).toString()));
            } catch (IllegalArgumentException e) {
                // Ignore the malformed media range.
            }
        }
    }
Finds the {@link MediaType} in this {@link List} that matches one of the specified media ranges.

@return the most preferred {@link MediaType} that matches one of the specified media ranges.
        {@code null} if there are no matches or {@code ranges} does not contain any valid ranges.
core/src/main/java/com/linecorp/armeria/common/MediaTypeSet.java