Search in sources :

Example 1 with FormHttpMessageReader

use of cn.taketoday.http.codec.FormHttpMessageReader in project today-infrastructure by TAKETODAY.

the class BaseDefaultCodecs method initTypedReaders.

/**
 * Reset and initialize typed readers.
 */
protected void initTypedReaders() {
    this.typedReaders.clear();
    if (!this.registerDefaults) {
        return;
    }
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new ByteArrayDecoder()));
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new DataBufferDecoder()));
    if (nettyByteBufPresent) {
        addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new NettyByteBufDecoder()));
    }
    addCodec(this.typedReaders, new ResourceHttpMessageReader(new ResourceDecoder()));
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly()));
    if (protobufPresent) {
        addCodec(this.typedReaders, new DecoderHttpMessageReader<>(this.protobufDecoder != null ? (ProtobufDecoder) this.protobufDecoder : new ProtobufDecoder()));
    }
    addCodec(this.typedReaders, new FormHttpMessageReader());
    // client vs server..
    extendTypedReaders(this.typedReaders);
}
Also used : FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) NettyByteBufDecoder(cn.taketoday.core.codec.NettyByteBufDecoder) AbstractDataBufferDecoder(cn.taketoday.core.codec.AbstractDataBufferDecoder) DataBufferDecoder(cn.taketoday.core.codec.DataBufferDecoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) ResourceDecoder(cn.taketoday.core.codec.ResourceDecoder) ByteBufferDecoder(cn.taketoday.core.codec.ByteBufferDecoder) ByteArrayDecoder(cn.taketoday.core.codec.ByteArrayDecoder)

Example 2 with FormHttpMessageReader

use of cn.taketoday.http.codec.FormHttpMessageReader in project today-infrastructure by TAKETODAY.

the class ServerCodecConfigurerTests method enableRequestLoggingDetailsWithCustomCodecs.

@Test
public void enableRequestLoggingDetailsWithCustomCodecs() {
    this.configurer.registerDefaults(false);
    this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
    CodecConfigurer.CustomCodecs customCodecs = this.configurer.customCodecs();
    customCodecs.register(new FormHttpMessageReader());
    customCodecs.registerWithDefaultConfig(new FormHttpMessageReader());
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    assertThat(((FormHttpMessageReader) readers.get(0)).isEnableLoggingRequestDetails()).isFalse();
    assertThat(((FormHttpMessageReader) readers.get(1)).isEnableLoggingRequestDetails()).isTrue();
}
Also used : FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) DefaultPartHttpMessageReader(cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) MultipartHttpMessageReader(cn.taketoday.http.codec.multipart.MultipartHttpMessageReader) DecoderHttpMessageReader(cn.taketoday.http.codec.DecoderHttpMessageReader) HttpMessageReader(cn.taketoday.http.codec.HttpMessageReader) PartEventHttpMessageReader(cn.taketoday.http.codec.multipart.PartEventHttpMessageReader) CodecConfigurer(cn.taketoday.http.codec.CodecConfigurer) ServerCodecConfigurer(cn.taketoday.http.codec.ServerCodecConfigurer) Test(org.junit.jupiter.api.Test)

Example 3 with FormHttpMessageReader

use of cn.taketoday.http.codec.FormHttpMessageReader in project today-infrastructure by TAKETODAY.

the class ClientCodecConfigurerTests method maxInMemorySize.

@Test
public void maxInMemorySize() {
    int size = 99;
    this.configurer.defaultCodecs().maxInMemorySize(size);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    assertThat(readers.size()).isEqualTo(12);
    assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ByteBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((DataBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((NettyByteBufDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ResourceDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ProtobufDecoder) getNextDecoder(readers)).getMaxMessageSize()).isEqualTo(size);
    assertThat(((FormHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2SmileDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    ServerSentEventHttpMessageReader reader = (ServerSentEventHttpMessageReader) nextReader(readers);
    assertThat(reader.getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) reader.getDecoder()).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
}
Also used : Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) StringDecoder(cn.taketoday.core.codec.StringDecoder) ResourceDecoder(cn.taketoday.core.codec.ResourceDecoder) ByteBufferDecoder(cn.taketoday.core.codec.ByteBufferDecoder) ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DecoderHttpMessageReader(cn.taketoday.http.codec.DecoderHttpMessageReader) HttpMessageReader(cn.taketoday.http.codec.HttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) NettyByteBufDecoder(cn.taketoday.core.codec.NettyByteBufDecoder) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DataBufferDecoder(cn.taketoday.core.codec.DataBufferDecoder) ByteArrayDecoder(cn.taketoday.core.codec.ByteArrayDecoder) Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder) Test(org.junit.jupiter.api.Test)

Example 4 with FormHttpMessageReader

use of cn.taketoday.http.codec.FormHttpMessageReader in project today-framework by TAKETODAY.

the class BaseDefaultCodecs method initTypedReaders.

/**
 * Reset and initialize typed readers.
 */
protected void initTypedReaders() {
    this.typedReaders.clear();
    if (!this.registerDefaults) {
        return;
    }
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new ByteArrayDecoder()));
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new ByteBufferDecoder()));
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new DataBufferDecoder()));
    if (nettyByteBufPresent) {
        addCodec(this.typedReaders, new DecoderHttpMessageReader<>(new NettyByteBufDecoder()));
    }
    addCodec(this.typedReaders, new ResourceHttpMessageReader(new ResourceDecoder()));
    addCodec(this.typedReaders, new DecoderHttpMessageReader<>(StringDecoder.textPlainOnly()));
    if (protobufPresent) {
        addCodec(this.typedReaders, new DecoderHttpMessageReader<>(this.protobufDecoder != null ? (ProtobufDecoder) this.protobufDecoder : new ProtobufDecoder()));
    }
    addCodec(this.typedReaders, new FormHttpMessageReader());
    // client vs server..
    extendTypedReaders(this.typedReaders);
}
Also used : FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) NettyByteBufDecoder(cn.taketoday.core.codec.NettyByteBufDecoder) AbstractDataBufferDecoder(cn.taketoday.core.codec.AbstractDataBufferDecoder) DataBufferDecoder(cn.taketoday.core.codec.DataBufferDecoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) ResourceDecoder(cn.taketoday.core.codec.ResourceDecoder) ByteBufferDecoder(cn.taketoday.core.codec.ByteBufferDecoder) ByteArrayDecoder(cn.taketoday.core.codec.ByteArrayDecoder)

Example 5 with FormHttpMessageReader

use of cn.taketoday.http.codec.FormHttpMessageReader in project today-framework by TAKETODAY.

the class ClientCodecConfigurerTests method maxInMemorySize.

@Test
public void maxInMemorySize() {
    int size = 99;
    this.configurer.defaultCodecs().maxInMemorySize(size);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    assertThat(readers.size()).isEqualTo(12);
    assertThat(((ByteArrayDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ByteBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((DataBufferDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((NettyByteBufDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ResourceDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((ProtobufDecoder) getNextDecoder(readers)).getMaxMessageSize()).isEqualTo(size);
    assertThat(((FormHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2SmileDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    ServerSentEventHttpMessageReader reader = (ServerSentEventHttpMessageReader) nextReader(readers);
    assertThat(reader.getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) reader.getDecoder()).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
}
Also used : Jackson2JsonDecoder(cn.taketoday.http.codec.json.Jackson2JsonDecoder) ProtobufDecoder(cn.taketoday.http.codec.protobuf.ProtobufDecoder) StringDecoder(cn.taketoday.core.codec.StringDecoder) ResourceDecoder(cn.taketoday.core.codec.ResourceDecoder) ByteBufferDecoder(cn.taketoday.core.codec.ByteBufferDecoder) ResourceHttpMessageReader(cn.taketoday.http.codec.ResourceHttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DecoderHttpMessageReader(cn.taketoday.http.codec.DecoderHttpMessageReader) HttpMessageReader(cn.taketoday.http.codec.HttpMessageReader) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) NettyByteBufDecoder(cn.taketoday.core.codec.NettyByteBufDecoder) ServerSentEventHttpMessageReader(cn.taketoday.http.codec.ServerSentEventHttpMessageReader) DataBufferDecoder(cn.taketoday.core.codec.DataBufferDecoder) ByteArrayDecoder(cn.taketoday.core.codec.ByteArrayDecoder) Jackson2SmileDecoder(cn.taketoday.http.codec.json.Jackson2SmileDecoder) Test(org.junit.jupiter.api.Test)

Aggregations

FormHttpMessageReader (cn.taketoday.http.codec.FormHttpMessageReader)10 ByteBufferDecoder (cn.taketoday.core.codec.ByteBufferDecoder)8 DecoderHttpMessageReader (cn.taketoday.http.codec.DecoderHttpMessageReader)8 HttpMessageReader (cn.taketoday.http.codec.HttpMessageReader)8 ResourceHttpMessageReader (cn.taketoday.http.codec.ResourceHttpMessageReader)8 ByteArrayDecoder (cn.taketoday.core.codec.ByteArrayDecoder)6 DataBufferDecoder (cn.taketoday.core.codec.DataBufferDecoder)6 NettyByteBufDecoder (cn.taketoday.core.codec.NettyByteBufDecoder)6 ResourceDecoder (cn.taketoday.core.codec.ResourceDecoder)6 Jackson2JsonDecoder (cn.taketoday.http.codec.json.Jackson2JsonDecoder)6 DefaultPartHttpMessageReader (cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader)6 MultipartHttpMessageReader (cn.taketoday.http.codec.multipart.MultipartHttpMessageReader)6 ProtobufDecoder (cn.taketoday.http.codec.protobuf.ProtobufDecoder)6 Test (org.junit.jupiter.api.Test)6 StringDecoder (cn.taketoday.core.codec.StringDecoder)4 Jackson2SmileDecoder (cn.taketoday.http.codec.json.Jackson2SmileDecoder)4 PartEventHttpMessageReader (cn.taketoday.http.codec.multipart.PartEventHttpMessageReader)4 MultiValueMap (cn.taketoday.core.MultiValueMap)2 AbstractDataBufferDecoder (cn.taketoday.core.codec.AbstractDataBufferDecoder)2 CodecConfigurer (cn.taketoday.http.codec.CodecConfigurer)2