HttpMessageWriter for writing a MultiValueMap<String, ?>
as multipart form data, i.e. "multipart/form-data", to the body
of a request.
The serialization of individual parts is delegated to other writers.
By default only String and Resource parts are supported but
you can configure others through a constructor argument.
This writer can be configured with a FormHttpMessageWriter to
delegate to. It is the preferred way of supporting both form data and
multipart data (as opposed to registering each writer separately) so that
when the MediaType is not specified and generics are not present on
the target element type, we can inspect the values in the actual map and
decide whether to write plain form data (String values only) or otherwise.
FormHttpMessageWriter
| Modifier and Type | Class and Description |
|---|---|
| private class |
| Modifier and Type | Field and Description |
|---|---|
| private static final Map | DEFAULT_HINTS
Suppress logging from individual part writers (full map logged at this level). |
| private final HttpMessageWriter | |
| private final Supplier |
| Access | Constructor and Description |
|---|---|
| public | |
| public | MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters)
Constructor with explicit list of writers for serializing parts. |
| public | MultipartHttpMessageWriter(List<HttpMessageWriter<?>>
the writers for serializing parts partWriters, HttpMessageWriter<MultiValueMap<String, String>> the fallback writer for form data, formWriter)null by defaultConstructor with explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only. |
| public | MultipartHttpMessageWriter(Supplier<List<HttpMessageWriter<?>>>
the supplier for writers for serializing parts partWritersSupplier, HttpMessageWriter<MultiValueMap<String, String>> the fallback writer for form data, formWriter)null by defaultConstructor with a supplier for an explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only. |
| Modifier and Type | Method and Description |
|---|---|
| public boolean | canWrite(ResolvableType
the type of object to check elementType, MediaType the media type for the write (possibly mediaType)null)Implements org. Whether the given object type is supported by this writer. |
| private <T> Flux | |
| private Flux | |
| public HttpMessageWriter | |
| public List | |
| private static List | |
| private boolean | |
| public Mono | write(Publisher<? extends MultiValueMap<String, ?>>
the objects to write inputStream, ResolvableType the type of objects in the stream which must have been
previously checked via elementType, MediaType canWrite(ResolvableType, MediaType)the content type for the write (possibly mediaType, ReactiveHttpOutputMessage null to
indicate that the default content type of the writer must be used)the message to write to outputMessage, Map<String, Object> additional information about how to encode and write hints)Implements org. Write a given stream of object to the output message. |
| private Mono | writeMultipart(MultiValueMap<String, ?> map, ReactiveHttpOutputMessage outputMessage, MediaType mediaType, Map<String, Object> hints)
|
| DEFAULT_HINTS | back to summary |
|---|---|
| private static final Map<String, Object> DEFAULT_HINTS Suppress logging from individual part writers (full map logged at this level). | |
| formWriter | back to summary |
|---|---|
| private final HttpMessageWriter<MultiValueMap<String, String>> formWriter
| |
| partWritersSupplier | back to summary |
|---|---|
| private final Supplier<List<HttpMessageWriter<?>>> partWritersSupplier | |
| MultipartHttpMessageWriter | back to summary |
|---|---|
| public MultipartHttpMessageWriter() Constructor with a default list of part writers (String and Resource). | |
| MultipartHttpMessageWriter | back to summary |
|---|---|
| public MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters) Constructor with explicit list of writers for serializing parts. | |
| MultipartHttpMessageWriter | back to summary |
|---|---|
| public MultipartHttpMessageWriter(List<HttpMessageWriter<?>> partWriters, HttpMessageWriter<MultiValueMap<String, String>> formWriter) Constructor with explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only.
| |
| MultipartHttpMessageWriter | back to summary |
|---|---|
| public MultipartHttpMessageWriter(Supplier<List<HttpMessageWriter<?>>> partWritersSupplier, HttpMessageWriter<MultiValueMap<String, String>> formWriter) Constructor with a supplier for an explicit list of writers for serializing parts and a writer for plain form data to fall back when no media type is specified and the actual map consists of String values only.
| |
| canWrite | back to summary |
|---|---|
| public boolean canWrite(ResolvableType elementType, MediaType mediaType) Implements org. Doc from org. Whether the given object type is supported by this writer.
| |
| encodePart | back to summary |
|---|---|
private <T> Flux
| |
| encodePartValues | back to summary |
|---|---|
| private Flux | |
| getFormWriter | back to summary |
|---|---|
| public HttpMessageWriter Return the configured form writer.
| |
| getPartWriters | back to summary |
|---|---|
| public List Return the configured part writers.
| |
| initMediaTypes | back to summary |
|---|---|
| private static List | |
| isMultipart | back to summary |
|---|---|
| private boolean isMultipart(MultiValueMap<String, ?> map, MediaType contentType) | |
| write | back to summary |
|---|---|
| public Mono Implements org. Doc from org. Write a given stream of object to the output message.
| |
| writeMultipart | back to summary |
|---|---|
| private Mono | |
| Modifier and Type | Field and Description |
|---|---|
| private Flux | |
| private final DataBufferFactory | |
| private final AtomicBoolean | |
| private final HttpHeaders |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| public void | beforeCommit(Supplier<? extends Mono<Void>>
the action to apply action)Implements org. Register an action to apply just before the HttpOutputMessage is committed. |
| public DataBufferFactory | bufferFactory()
Implements org. Return a |
| public Flux | |
| public HttpHeaders | getHeaders()
Implements org. Return the headers of this message. |
| public boolean | isCommitted()
Implements org. Whether the HttpOutputMessage is committed. |
| public Mono | setComplete()
Implements org. Indicate that message handling is complete, allowing for any cleanup or
end-of-processing tasks to be performed such as applying header changes
made via |
| public Mono | writeAndFlushWith(Publisher<? extends Publisher<? extends DataBuffer>>
the body content publisher body)Implements org. Use the given |
| public Mono | writeWith(Publisher<? extends DataBuffer>
the body content publisher body)Implements org. Use the given |
| body | back to summary |
|---|---|
| private Flux<DataBuffer> body
| |
| bufferFactory | back to summary |
|---|---|
| private final DataBufferFactory bufferFactory | |
| committed | back to summary |
|---|---|
| private final AtomicBoolean committed | |
| headers | back to summary |
|---|---|
| private final HttpHeaders headers | |
| MultipartHttpOutputMessage | back to summary |
|---|---|
| public MultipartHttpOutputMessage(DataBufferFactory bufferFactory) | |
| beforeCommit | back to summary |
|---|---|
| public void beforeCommit(Supplier<? extends Mono<Void>> action) Implements org. Doc from org. Register an action to apply just before the HttpOutputMessage is committed. Note the supplied action must be properly deferred,
e.g. via | |
| bufferFactory | back to summary |
|---|---|
| public DataBufferFactory bufferFactory() Implements org. Doc from org. Return a
| |
| getBody | back to summary |
|---|---|
| public Flux | |
| getHeaders | back to summary |
|---|---|
| public HttpHeaders getHeaders() Implements org. Doc from org. Return the headers of this message.
| |
| isCommitted | back to summary |
|---|---|
| public boolean isCommitted() Implements org. Doc from org. Whether the HttpOutputMessage is committed.
| |
| setComplete | back to summary |
|---|---|
| public Mono Implements org. Doc from org. Indicate that message handling is complete, allowing for any cleanup or
end-of-processing tasks to be performed such as applying header changes
made via This method should be automatically invoked at the end of message processing so typically applications should not have to invoke it. If invoked multiple times it should have no side effects. | |
| writeAndFlushWith | back to summary |
|---|---|
| public Mono Implements org. Doc from org. Use the given | |
| writeWith | back to summary |
|---|---|
| public Mono Implements org. Doc from org. Use the given | |