private static boolean isFormData(@Nullable MediaType contentType) { return contentType != null && contentType.belongsTo(MediaType.FORM_DATA); }
/** * Finds the {@link MediaType} in this {@link List} that matches the specified media range. * * @return the {@link MediaType} that matches the specified media range. * {@link Optional#empty()} if there are no matches */ public Optional<MediaType> match(MediaType range) { requireNonNull(range, "range"); for (MediaType candidate : mediaTypes) { if (candidate.belongsTo(range)) { // With only one specified range, there is no way for candidates to have priority over each // other, we just return the first match. return Optional.of(candidate); } } return Optional.empty(); }
final MediaType type = MediaType.parse(value); for (MediaType producibleMediaType : producibleMediaTypes) { if (producibleMediaType.belongsTo(type)) { selectedTypes.add(type); break;
if (!candidate.belongsTo(range)) { continue;
/** * Creates a {@link SamlParameters} instance with the specified {@link AggregatedHttpMessage}. */ SamlParameters(AggregatedHttpMessage msg) { requireNonNull(msg, "msg"); final MediaType contentType = msg.headers().contentType(); final QueryStringDecoder decoder; if (contentType != null && contentType.belongsTo(MediaType.FORM_DATA)) { final String query = msg.content().toString( contentType.charset().orElse(StandardCharsets.UTF_8)); decoder = new QueryStringDecoder(query, false); } else { final String path = msg.path(); assert path != null : "path"; decoder = new QueryStringDecoder(path, true); } parameters = decoder.parameters(); }
/** * Creates a {@link SamlParameters} instance with the specified {@link AggregatedHttpMessage}. */ SamlParameters(AggregatedHttpMessage msg) { requireNonNull(msg, "msg"); final MediaType contentType = msg.headers().contentType(); final QueryStringDecoder decoder; if (contentType != null && contentType.belongsTo(MediaType.FORM_DATA)) { final String query = msg.content().toString( contentType.charset().orElse(StandardCharsets.UTF_8)); decoder = new QueryStringDecoder(query, false); } else { final String path = msg.path(); assert path != null : "path"; decoder = new QueryStringDecoder(path, true); } parameters = decoder.parameters(); }