Search in sources :

Example 1 with FormHttpMessageWriter

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

the class ClientCodecConfigurerTests method enableLoggingRequestDetails.

@Test
public void enableLoggingRequestDetails() {
    this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
    List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
    MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class);
    assertThat(multipartWriter.isEnableLoggingRequestDetails()).isTrue();
    FormHttpMessageWriter formWriter = (FormHttpMessageWriter) multipartWriter.getFormWriter();
    assertThat(formWriter).isNotNull();
    assertThat(formWriter.isEnableLoggingRequestDetails()).isTrue();
}
Also used : MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Example 2 with FormHttpMessageWriter

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

the class ClientCodecConfigurerTests method enableLoggingRequestDetails.

@Test
public void enableLoggingRequestDetails() {
    this.configurer.defaultCodecs().enableLoggingRequestDetails(true);
    List<HttpMessageWriter<?>> writers = this.configurer.getWriters();
    MultipartHttpMessageWriter multipartWriter = findCodec(writers, MultipartHttpMessageWriter.class);
    assertThat(multipartWriter.isEnableLoggingRequestDetails()).isTrue();
    FormHttpMessageWriter formWriter = (FormHttpMessageWriter) multipartWriter.getFormWriter();
    assertThat(formWriter).isNotNull();
    assertThat(formWriter.isEnableLoggingRequestDetails()).isTrue();
}
Also used : MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) ProtobufHttpMessageWriter(cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) Test(org.junit.jupiter.api.Test)

Example 3 with FormHttpMessageWriter

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

the class ClientDefaultCodecsImpl method extendTypedWriters.

@Override
protected void extendTypedWriters(List<HttpMessageWriter<?>> typedWriters) {
    addCodec(typedWriters, new MultipartHttpMessageWriter(getPartWriters(), new FormHttpMessageWriter()));
    addCodec(typedWriters, new PartEventHttpMessageWriter());
}
Also used : PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter)

Example 4 with FormHttpMessageWriter

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

the class BodyInsertersTests method createContext.

@BeforeEach
public void createContext() {
    final List<HttpMessageWriter<?>> messageWriters = new ArrayList<>();
    messageWriters.add(new EncoderHttpMessageWriter<>(new ByteBufferEncoder()));
    messageWriters.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.textPlainOnly()));
    messageWriters.add(new ResourceHttpMessageWriter());
    // messageWriters.add(new EncoderHttpMessageWriter<>(new Jaxb2XmlEncoder()));
    Jackson2JsonEncoder jsonEncoder = new Jackson2JsonEncoder();
    messageWriters.add(new EncoderHttpMessageWriter<>(jsonEncoder));
    messageWriters.add(new ServerSentEventHttpMessageWriter(jsonEncoder));
    messageWriters.add(new FormHttpMessageWriter());
    messageWriters.add(new EncoderHttpMessageWriter<>(CharSequenceEncoder.allMimeTypes()));
    messageWriters.add(new MultipartHttpMessageWriter(messageWriters));
    this.context = new BodyInserter.Context() {

        @Override
        public List<HttpMessageWriter<?>> messageWriters() {
            return messageWriters;
        }

        @Override
        public Optional<ServerHttpRequest> serverRequest() {
            return Optional.empty();
        }

        @Override
        public Map<String, Object> hints() {
            return hints;
        }
    };
    this.hints = new HashMap<>();
}
Also used : ByteBufferEncoder(cn.taketoday.core.codec.ByteBufferEncoder) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) EncoderHttpMessageWriter(cn.taketoday.http.codec.EncoderHttpMessageWriter) HttpMessageWriter(cn.taketoday.http.codec.HttpMessageWriter) ServerSentEventHttpMessageWriter(cn.taketoday.http.codec.ServerSentEventHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) Optional(java.util.Optional) ArrayList(java.util.ArrayList) ServerSentEventHttpMessageWriter(cn.taketoday.http.codec.ServerSentEventHttpMessageWriter) Jackson2JsonEncoder(cn.taketoday.http.codec.json.Jackson2JsonEncoder) ResourceHttpMessageWriter(cn.taketoday.http.codec.ResourceHttpMessageWriter) List(java.util.List) ArrayList(java.util.ArrayList) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) LinkedMultiValueMap(cn.taketoday.core.LinkedMultiValueMap) Map(java.util.Map) HashMap(java.util.HashMap) MultiValueMap(cn.taketoday.core.MultiValueMap) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 5 with FormHttpMessageWriter

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

the class ClientDefaultCodecsImpl method extendTypedWriters.

@Override
protected void extendTypedWriters(List<HttpMessageWriter<?>> typedWriters) {
    addCodec(typedWriters, new MultipartHttpMessageWriter(getPartWriters(), new FormHttpMessageWriter()));
    addCodec(typedWriters, new PartEventHttpMessageWriter());
}
Also used : PartEventHttpMessageWriter(cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter) MultipartHttpMessageWriter(cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter) FormHttpMessageWriter(cn.taketoday.http.codec.FormHttpMessageWriter)

Aggregations

FormHttpMessageWriter (cn.taketoday.http.codec.FormHttpMessageWriter)6 MultipartHttpMessageWriter (cn.taketoday.http.codec.multipart.MultipartHttpMessageWriter)6 EncoderHttpMessageWriter (cn.taketoday.http.codec.EncoderHttpMessageWriter)4 HttpMessageWriter (cn.taketoday.http.codec.HttpMessageWriter)4 ResourceHttpMessageWriter (cn.taketoday.http.codec.ResourceHttpMessageWriter)4 PartEventHttpMessageWriter (cn.taketoday.http.codec.multipart.PartEventHttpMessageWriter)4 LinkedMultiValueMap (cn.taketoday.core.LinkedMultiValueMap)2 MultiValueMap (cn.taketoday.core.MultiValueMap)2 ByteBufferEncoder (cn.taketoday.core.codec.ByteBufferEncoder)2 ServerSentEventHttpMessageWriter (cn.taketoday.http.codec.ServerSentEventHttpMessageWriter)2 Jackson2JsonEncoder (cn.taketoday.http.codec.json.Jackson2JsonEncoder)2 ProtobufHttpMessageWriter (cn.taketoday.http.codec.protobuf.ProtobufHttpMessageWriter)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Optional (java.util.Optional)2 BeforeEach (org.junit.jupiter.api.BeforeEach)2 Test (org.junit.jupiter.api.Test)2