/** * Create a {@code StringDecoder} for {@code "text/plain"}. */ public static StringDecoder textPlainOnly() { return textPlainOnly(DEFAULT_DELIMITERS, true); }
/** * Create a {@code StringDecoder} for {@code "text/plain"}. * @param ignored ignored * @deprecated as of Spring 5.0.4, in favor of {@link #textPlainOnly()} or * {@link #textPlainOnly(List, boolean)} */ @Deprecated public static StringDecoder textPlainOnly(boolean ignored) { return textPlainOnly(); }
/** * Create a {@code StringDecoder} for {@code "text/plain"}. */ public static StringDecoder textPlainOnly() { return textPlainOnly(DEFAULT_DELIMITERS, true); }
/** * Create a {@code StringDecoder} for {@code "text/plain"}. * @param ignored ignored * @deprecated as of Spring 5.0.4, in favor of {@link #textPlainOnly()} or * {@link #textPlainOnly(List, boolean)} */ @Deprecated public static StringDecoder textPlainOnly(boolean ignored) { return textPlainOnly(); }
/** * Return readers that support specific types. */ final List<HttpMessageReader<?>> getTypedReaders() { if (!this.registerDefaults) { return Collections.emptyList(); } List<HttpMessageReader<?>> readers = new ArrayList<>(); readers.add(new DecoderHttpMessageReader<>(new ByteArrayDecoder())); readers.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder())); readers.add(new DecoderHttpMessageReader<>(new DataBufferDecoder())); readers.add(new DecoderHttpMessageReader<>(new ResourceDecoder())); readers.add(new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly())); if (protobufPresent) { Decoder<?> decoder = this.protobufDecoder != null ? this.protobufDecoder : new ProtobufDecoder(); readers.add(new DecoderHttpMessageReader<>(decoder)); } FormHttpMessageReader formReader = new FormHttpMessageReader(); formReader.setEnableLoggingRequestDetails(this.enableLoggingRequestDetails); readers.add(formReader); extendTypedReaders(readers); return readers; }
/** * Return readers that support specific types. */ final List<HttpMessageReader<?>> getTypedReaders() { if (!this.registerDefaults) { return Collections.emptyList(); } List<HttpMessageReader<?>> readers = new ArrayList<>(); readers.add(new DecoderHttpMessageReader<>(new ByteArrayDecoder())); readers.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder())); readers.add(new DecoderHttpMessageReader<>(new DataBufferDecoder())); readers.add(new DecoderHttpMessageReader<>(new ResourceDecoder())); readers.add(new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly())); if (protobufPresent) { Decoder<?> decoder = this.protobufDecoder != null ? this.protobufDecoder : new ProtobufDecoder(); readers.add(new DecoderHttpMessageReader<>(decoder)); } FormHttpMessageReader formReader = new FormHttpMessageReader(); formReader.setEnableLoggingRequestDetails(this.enableLoggingRequestDetails); readers.add(formReader); extendTypedReaders(readers); return readers; }
@Override protected void configureHttpMessageCodecs(ServerCodecConfigurer configurer) { configurer.registerDefaults(false); configurer.customCodecs().decoder(StringDecoder.textPlainOnly()); configurer.customCodecs().decoder(new Jaxb2XmlDecoder()); configurer.customCodecs().encoder(CharSequenceEncoder.textPlainOnly()); configurer.customCodecs().encoder(new Jaxb2XmlEncoder()); } }
assertEquals(MediaType.APPLICATION_JSON_UTF8, part.headers().getContentType()); String value = StringDecoder.textPlainOnly(false).decodeToMono(part.content(), ResolvableType.forClass(String.class), MediaType.TEXT_PLAIN, Collections.emptyMap()).block(Duration.ZERO); assertEquals("publisher", part.name()); value = StringDecoder.textPlainOnly(false).decodeToMono(part.content(), ResolvableType.forClass(String.class), MediaType.TEXT_PLAIN, Collections.emptyMap()).block(Duration.ZERO);
/** * Create a {@code StringDecoder} for {@code "text/plain"}. */ public static StringDecoder textPlainOnly() { return textPlainOnly(DEFAULT_DELIMITERS, true); }
/** * Create a {@code StringDecoder} for {@code "text/plain"}. */ public static StringDecoder textPlainOnly() { return textPlainOnly(DEFAULT_DELIMITERS, true); }
/** * Create a {@code StringDecoder} for {@code "text/plain"}. * @param ignored ignored * @deprecated as of Spring 5.0.4, in favor of {@link #textPlainOnly()} or * {@link #textPlainOnly(List, boolean)}. */ @Deprecated public static StringDecoder textPlainOnly(boolean ignored) { return textPlainOnly(); }
/** * Create a {@code StringDecoder} for {@code "text/plain"}. * @param ignored ignored * @deprecated as of Spring 5.0.4, in favor of {@link #textPlainOnly()} or * {@link #textPlainOnly(List, boolean)} */ @Deprecated public static StringDecoder textPlainOnly(boolean ignored) { return textPlainOnly(); }
/** * Return readers that support specific types. */ final List<HttpMessageReader<?>> getTypedReaders() { if (!this.registerDefaults) { return Collections.emptyList(); } List<HttpMessageReader<?>> readers = new ArrayList<>(); readers.add(new DecoderHttpMessageReader<>(new ByteArrayDecoder())); readers.add(new DecoderHttpMessageReader<>(new ByteBufferDecoder())); readers.add(new DecoderHttpMessageReader<>(new DataBufferDecoder())); readers.add(new DecoderHttpMessageReader<>(new ResourceDecoder())); readers.add(new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly())); if (protobufPresent) { Decoder<?> decoder = this.protobufDecoder != null ? this.protobufDecoder : new ProtobufDecoder(); readers.add(new DecoderHttpMessageReader<>(decoder)); } FormHttpMessageReader formReader = new FormHttpMessageReader(); formReader.setEnableLoggingRequestDetails(this.enableLoggingRequestDetails); readers.add(formReader); extendTypedReaders(readers); return readers; }
@Override protected void register(GenericApplicationContext context, CodecConfigurer configurer) { configurer.customCodecs().encoder(textPlainOnly ? CharSequenceEncoder.textPlainOnly() : CharSequenceEncoder.allMimeTypes()); configurer.customCodecs().decoder(textPlainOnly ? StringDecoder.textPlainOnly() : StringDecoder.allMimeTypes()); } }