org.springframework.http.codec.FormHttpMessageWriter Java Examples
The following examples show how to use
org.springframework.http.codec.FormHttpMessageWriter.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: BodyInsertersTests.java From spring-analysis-note with MIT License | 5 votes |
@Before 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<>(); }
Example #2
Source File: ClientDefaultCodecsImpl.java From spring-analysis-note with MIT License | 5 votes |
@Override protected void extendTypedWriters(List<HttpMessageWriter<?>> typedWriters) { FormHttpMessageWriter formWriter = new FormHttpMessageWriter(); formWriter.setEnableLoggingRequestDetails(isEnableLoggingRequestDetails()); MultipartHttpMessageWriter multipartWriter = new MultipartHttpMessageWriter(getPartWriters(), formWriter); multipartWriter.setEnableLoggingRequestDetails(isEnableLoggingRequestDetails()); typedWriters.add(multipartWriter); }
Example #3
Source File: WebExchangeDataBinderTests.java From spring-analysis-note with MIT License | 5 votes |
private ServerWebExchange exchange(MultiValueMap<String, String> formData) { MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.POST, "/"); new FormHttpMessageWriter().write(Mono.just(formData), forClassWithGenerics(MultiValueMap.class, String.class, String.class), MediaType.APPLICATION_FORM_URLENCODED, request, Collections.emptyMap()).block(); return MockServerWebExchange.from( MockServerHttpRequest .post("/") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .body(request.getBody())); }
Example #4
Source File: BodyInsertersTests.java From java-technology-stack with MIT License | 5 votes |
@Before 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<>(); }
Example #5
Source File: ClientDefaultCodecsImpl.java From java-technology-stack with MIT License | 5 votes |
@Override protected void extendTypedWriters(List<HttpMessageWriter<?>> typedWriters) { FormHttpMessageWriter formWriter = new FormHttpMessageWriter(); formWriter.setEnableLoggingRequestDetails(isEnableLoggingRequestDetails()); MultipartHttpMessageWriter multipartWriter = new MultipartHttpMessageWriter(getPartWriters(), formWriter); multipartWriter.setEnableLoggingRequestDetails(isEnableLoggingRequestDetails()); typedWriters.add(multipartWriter); }
Example #6
Source File: WebExchangeDataBinderTests.java From java-technology-stack with MIT License | 5 votes |
private ServerWebExchange exchange(MultiValueMap<String, String> formData) { MockClientHttpRequest request = new MockClientHttpRequest(HttpMethod.POST, "/"); new FormHttpMessageWriter().write(Mono.just(formData), forClassWithGenerics(MultiValueMap.class, String.class, String.class), MediaType.APPLICATION_FORM_URLENCODED, request, Collections.emptyMap()).block(); return MockServerWebExchange.from( MockServerHttpRequest .post("/") .contentType(MediaType.APPLICATION_FORM_URLENCODED) .body(request.getBody())); }
Example #7
Source File: MultipartHttpMessageWriter.java From spring-analysis-note with MIT License | 4 votes |
/** * Constructor with explicit list of writers for serializing parts. */ public MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters) { this(partWriters, new FormHttpMessageWriter()); }
Example #8
Source File: MultipartHttpMessageWriter.java From java-technology-stack with MIT License | 4 votes |
/** * Constructor with explicit list of writers for serializing parts. */ public MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters) { this(partWriters, new FormHttpMessageWriter()); }
Example #9
Source File: FormCodecInitializer.java From spring-fu with Apache License 2.0 | 4 votes |
@Override protected void register(GenericApplicationContext context, CodecConfigurer configurer) { configurer.customCodecs().writer(new FormHttpMessageWriter()); configurer.customCodecs().reader(new FormHttpMessageReader()); }