Package org.springframework.http.codec.multipart

# Class PartEventHttpMessageReader

java.lang.Object
org.springframework.http.codec.LoggingCodecSupport
org.springframework.http.codec.multipart.PartEventHttpMessageReader

All Implemented Interfaces:
  `HttpMessageReader<PartEvent>`

public class PartEventHttpMessageReader extends LoggingCodecSupport implements HttpMessageReader<PartEvent>
`HttpMessageReader` for parsing `"multipart/form-data"` requests to a stream of `PartEvent` elements.

Since:
  6.0
Author:
  Arjen Poutsma
See Also:
  - `PartEvent`

## Field Summary

### Fields inherited from class org.springframework.http.codec.LoggingCodecSupport

`logger`

## Constructor Summary

Constructors
Constructor
Description
`PartEventHttpMessageReader()`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`canRead(org.springframework.core.ResolvableType elementType, MediaType mediaType)`
Whether the given object type is supported by this reader.
`int`
`getMaxInMemorySize()`
Get the `configured` maximum in-memory size.
`List<MediaType>`
`getReadableMediaTypes()`
Return the list of media types supported by this reader.
`reactor.core.publisher.Flux<PartEvent>`
`read(org.springframework.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)`
Read from the input message and decode to a stream of objects.
`reactor.core.publisher.Mono<PartEvent>`
`readMono(org.springframework.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)`
Read from the input message and decode to a single object.
`void`
`setHeadersCharset(Charset headersCharset)`
Set the character set used to decode headers.
`void`
`setMaxHeadersSize(int byteCount)`
Configure the maximum amount of memory that is allowed per headers section of each part.
`void`
`setMaxInMemorySize(int maxInMemorySize)`
Configure the maximum amount of memory allowed for form fields.
`void`
`setMaxParts(int maxParts)`
Specify the maximum number of parts allowed in a given multipart request.
`void`
`setMaxPartSize(long maxPartSize)`
Configure the maximum size allowed for any part.

### Methods inherited from class org.springframework.http.codec.LoggingCodecSupport

`isEnableLoggingRequestDetails, setEnableLoggingRequestDetails`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.http.codec.HttpMessageReader

`getReadableMediaTypes, read, readMono`

## Constructor Details

### PartEventHttpMessageReader

public PartEventHttpMessageReader()

## Method Details

### getMaxInMemorySize

public int getMaxInMemorySize()
Get the `configured` maximum in-memory size.

### setMaxInMemorySize

public void setMaxInMemorySize(int maxInMemorySize)
Configure the maximum amount of memory allowed for form fields. When the limit is exceeded, form fields parts are rejected with `DataBufferLimitException`.

By default this is set to 256K.

Parameters:
  `maxInMemorySize` - the in-memory limit in bytes; if set to -1 the entire contents will be stored in memory

### setMaxHeadersSize

public void setMaxHeadersSize(int byteCount)
Configure the maximum amount of memory that is allowed per headers section of each part. Defaults to 10K.

Parameters:
  `byteCount` - the maximum amount of memory for headers

### setMaxParts

public void setMaxParts(int maxParts)
Specify the maximum number of parts allowed in a given multipart request.

By default this is set to -1, meaning that there is no maximum.

Since:
  6.1

### setMaxPartSize

public void setMaxPartSize(long maxPartSize)
Configure the maximum size allowed for any part.

By default this is set to -1, meaning that there is no maximum.

Since:
  6.1

### setHeadersCharset

public void setHeadersCharset(Charset headersCharset)
Set the character set used to decode headers.

Defaults to UTF-8 as per RFC 7578.

Parameters:
  `headersCharset` - the charset to use for decoding headers
See Also:
  - RFC-7578 Section 5.1

### getReadableMediaTypes

public List<MediaType> getReadableMediaTypes()
Description copied from interface: `HttpMessageReader`
Return the list of media types supported by this reader. The list may not apply to every possible target element type and calls to this method should typically be guarded via `canWrite(elementType, null)`. The list may also exclude media types supported only for a specific element type. Alternatively, use `HttpMessageReader.getReadableMediaTypes(ResolvableType)` for a more precise list.

Specified by:
  `getReadableMediaTypes` in interface `HttpMessageReader<PartEvent>`
Returns:
  the general list of supported media types

### canRead

public boolean canRead(org.springframework.core.ResolvableType elementType, @Nullable MediaType mediaType)
Description copied from interface: `HttpMessageReader`
Whether the given object type is supported by this reader.

Specified by:
  `canRead` in interface `HttpMessageReader<PartEvent>`
Parameters:
  `elementType` - the type of object to check
  `mediaType` - the media type for the read (possibly `null`)
Returns:
  `true` if readable, `false` otherwise

### readMono

public reactor.core.publisher.Mono<PartEvent> readMono(org.springframework.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
Description copied from interface: `HttpMessageReader`
Read from the input message and decode to a single object.

Specified by:
  `readMono` in interface `HttpMessageReader<PartEvent>`
Parameters:
  `elementType` - the type of objects in the stream which must have been previously checked via `HttpMessageReader.canRead(ResolvableType, MediaType)`
  `message` - the message to read from
  `hints` - additional information about how to read and decode the input
Returns:
  the decoded object

### read

public reactor.core.publisher.Flux<PartEvent> read(org.springframework.core.ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
Description copied from interface: `HttpMessageReader`
Read from the input message and decode to a stream of objects.

Specified by:
  `read` in interface `HttpMessageReader<PartEvent>`
Parameters:
  `elementType` - the type of objects in the stream which must have been previously checked via `HttpMessageReader.canRead(ResolvableType, MediaType)`
  `message` - the message to read from
  `hints` - additional information about how to read and decode the input
Returns:
  the decoded stream of elements