Search in sources :

Example 1 with MultipartHttpMessageReader

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

the class ServerDefaultCodecsImpl method extendTypedReaders.

@Override
protected void extendTypedReaders(List<HttpMessageReader<?>> typedReaders) {
    if (this.multipartReader != null) {
        addCodec(typedReaders, this.multipartReader);
    } else {
        DefaultPartHttpMessageReader partReader = new DefaultPartHttpMessageReader();
        addCodec(typedReaders, partReader);
        addCodec(typedReaders, new MultipartHttpMessageReader(partReader));
    }
    addCodec(typedReaders, new PartEventHttpMessageReader());
}
Also used : MultipartHttpMessageReader(cn.taketoday.http.codec.multipart.MultipartHttpMessageReader) DefaultPartHttpMessageReader(cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader) PartEventHttpMessageReader(cn.taketoday.http.codec.multipart.PartEventHttpMessageReader)

Example 2 with MultipartHttpMessageReader

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

the class ServerCodecConfigurerTests method enableRequestLoggingDetails.

@Test
public void enableRequestLoggingDetails() {
    this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    assertThat(findCodec(readers, FormHttpMessageReader.class).isEnableLoggingRequestDetails()).isTrue();
    MultipartHttpMessageReader multipartReader = findCodec(readers, MultipartHttpMessageReader.class);
    assertThat(multipartReader.isEnableLoggingRequestDetails()).isTrue();
    DefaultPartHttpMessageReader reader = (DefaultPartHttpMessageReader) multipartReader.getPartReader();
    assertThat(reader.isEnableLoggingRequestDetails()).isTrue();
}
Also used : 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) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) MultipartHttpMessageReader(cn.taketoday.http.codec.multipart.MultipartHttpMessageReader) DefaultPartHttpMessageReader(cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader) Test(org.junit.jupiter.api.Test)

Example 3 with MultipartHttpMessageReader

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

the class ServerDefaultCodecsImpl method extendTypedReaders.

@Override
protected void extendTypedReaders(List<HttpMessageReader<?>> typedReaders) {
    if (this.multipartReader != null) {
        addCodec(typedReaders, this.multipartReader);
    } else {
        DefaultPartHttpMessageReader partReader = new DefaultPartHttpMessageReader();
        addCodec(typedReaders, partReader);
        addCodec(typedReaders, new MultipartHttpMessageReader(partReader));
    }
    addCodec(typedReaders, new PartEventHttpMessageReader());
}
Also used : MultipartHttpMessageReader(cn.taketoday.http.codec.multipart.MultipartHttpMessageReader) DefaultPartHttpMessageReader(cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader) PartEventHttpMessageReader(cn.taketoday.http.codec.multipart.PartEventHttpMessageReader)

Example 4 with MultipartHttpMessageReader

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

the class ServerCodecConfigurerTests method maxInMemorySize.

@Test
public void maxInMemorySize() {
    int size = 99;
    this.configurer.defaultCodecs().maxInMemorySize(size);
    List<HttpMessageReader<?>> readers = this.configurer.getReaders();
    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(((DefaultPartHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size);
    MultipartHttpMessageReader multipartReader = (MultipartHttpMessageReader) nextReader(readers);
    DefaultPartHttpMessageReader reader = (DefaultPartHttpMessageReader) multipartReader.getPartReader();
    assertThat((reader).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((PartEventHttpMessageReader) nextReader(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2JsonDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((Jackson2SmileDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
    assertThat(((StringDecoder) getNextDecoder(readers)).getMaxInMemorySize()).isEqualTo(size);
}
Also used : MultipartHttpMessageReader(cn.taketoday.http.codec.multipart.MultipartHttpMessageReader) DefaultPartHttpMessageReader(cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader) 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) 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) FormHttpMessageReader(cn.taketoday.http.codec.FormHttpMessageReader) NettyByteBufDecoder(cn.taketoday.core.codec.NettyByteBufDecoder) PartEventHttpMessageReader(cn.taketoday.http.codec.multipart.PartEventHttpMessageReader) 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 5 with MultipartHttpMessageReader

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

the class ServerCodecConfigurerTests method cloneConfigurer.

@Test
public void cloneConfigurer() {
    ServerCodecConfigurer clone = this.configurer.clone();
    MultipartHttpMessageReader reader = new MultipartHttpMessageReader(new DefaultPartHttpMessageReader());
    Jackson2JsonEncoder encoder = new Jackson2JsonEncoder();
    clone.defaultCodecs().multipartReader(reader);
    clone.defaultCodecs().serverSentEventEncoder(encoder);
    // Clone has the customizations
    HttpMessageReader<?> actualReader = findCodec(clone.getReaders(), MultipartHttpMessageReader.class);
    ServerSentEventHttpMessageWriter actualWriter = findCodec(clone.getWriters(), ServerSentEventHttpMessageWriter.class);
    assertThat(actualReader).isSameAs(reader);
    assertThat(actualWriter.getEncoder()).isSameAs(encoder);
    // Original does not have the customizations
    actualReader = findCodec(this.configurer.getReaders(), MultipartHttpMessageReader.class);
    actualWriter = findCodec(this.configurer.getWriters(), ServerSentEventHttpMessageWriter.class);
    assertThat(actualReader).isNotSameAs(reader);
    assertThat(actualWriter.getEncoder()).isNotSameAs(encoder);
}
Also used : MultipartHttpMessageReader(cn.taketoday.http.codec.multipart.MultipartHttpMessageReader) DefaultPartHttpMessageReader(cn.taketoday.http.codec.multipart.DefaultPartHttpMessageReader) ServerSentEventHttpMessageWriter(cn.taketoday.http.codec.ServerSentEventHttpMessageWriter) ServerCodecConfigurer(cn.taketoday.http.codec.ServerCodecConfigurer) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) Test(org.junit.jupiter.api.Test)

Aggregations

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