Package org.springframework.http.codec
Class FormHttpMessageReader
- java.lang.Object
- org.springframework.http.codec.LoggingCodecSupport
- org.springframework.http.codec.FormHttpMessageReader
- All Implemented Interfaces:
HttpMessageReader<MultiValueMap<String,String>>
public class FormHttpMessageReader extends LoggingCodecSupport implements HttpMessageReader<MultiValueMap<String,String>>
Implementation of anHttpMessageReaderto read HTML form data, i.e. request body with media type"application/x-www-form-urlencoded".- Since:
- 5.0
- Author:
- Sebastien Deleuze, Rossen Stoyanchev
Field Summary
Fields Modifier and Type Field Description static CharsetDEFAULT_CHARSETThe default charset used by the reader.Fields inherited from class org.springframework.http.codec.LoggingCodecSupport
logger
Constructor Summary
Constructors Constructor Description FormHttpMessageReader()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancanRead(ResolvableType elementType, MediaType mediaType)Whether the given object type is supported by this reader.CharsetgetDefaultCharset()Return the configured default charset.intgetMaxInMemorySize()Return theconfiguredbyte count limit.List<MediaType>getReadableMediaTypes()Return theMediaType's that this reader supports.reactor.core.publisher.Flux<MultiValueMap<String,String>>read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)Read from the input message and encode to a stream of objects.reactor.core.publisher.Mono<MultiValueMap<String,String>>readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)Read from the input message and encode to a single object.voidsetDefaultCharset(Charset charset)Set the default character set to use for reading form data when the request Content-Type header does not explicitly specify it.voidsetMaxInMemorySize(int byteCount)Set the max number of bytes for input form data.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
read, readMono
Field Detail
DEFAULT_CHARSET
public static final Charset DEFAULT_CHARSET
The default charset used by the reader.
Constructor Detail
FormHttpMessageReader
public FormHttpMessageReader()
Method Detail
setDefaultCharset
public void setDefaultCharset(Charset charset)
Set the default character set to use for reading form data when the request Content-Type header does not explicitly specify it.By default this is set to "UTF-8".
getDefaultCharset
public Charset getDefaultCharset()
Return the configured default charset.
setMaxInMemorySize
public void setMaxInMemorySize(int byteCount)
Set the max number of bytes for input form data. As form data is buffered before it is parsed, this helps to limit the amount of buffering. Once the limit is exceeded,DataBufferLimitExceptionis raised.By default this is set to 256K.
- Parameters:
byteCount- the max number of bytes to buffer, or -1 for unlimited- Since:
- 5.1.11
getMaxInMemorySize
public int getMaxInMemorySize()
Return theconfiguredbyte count limit.- Since:
- 5.1.11
canRead
public boolean canRead(ResolvableType elementType, @Nullable MediaType mediaType)
Description copied from interface:HttpMessageReaderWhether the given object type is supported by this reader.- Specified by:
canReadin interfaceHttpMessageReader<MultiValueMap<String,String>>- Parameters:
elementType- the type of object to checkmediaType- the media type for the read (possiblynull)- Returns:
trueif readable,falseotherwise
read
public reactor.core.publisher.Flux<MultiValueMap<String,String>> read(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
Description copied from interface:HttpMessageReaderRead from the input message and encode to a stream of objects.- Specified by:
readin interfaceHttpMessageReader<MultiValueMap<String,String>>- Parameters:
elementType- the type of objects in the stream which must have been previously checked viaHttpMessageReader.canRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- Returns:
- the decoded stream of elements
readMono
public reactor.core.publisher.Mono<MultiValueMap<String,String>> readMono(ResolvableType elementType, ReactiveHttpInputMessage message, Map<String,Object> hints)
Description copied from interface:HttpMessageReaderRead from the input message and encode to a single object.- Specified by:
readMonoin interfaceHttpMessageReader<MultiValueMap<String,String>>- Parameters:
elementType- the type of objects in the stream which must have been previously checked viaHttpMessageReader.canRead(ResolvableType, MediaType)message- the message to read fromhints- additional information about how to read and decode the input- Returns:
- the decoded object
getReadableMediaTypes
public List<MediaType> getReadableMediaTypes()
Description copied from interface:HttpMessageReaderReturn theMediaType's that this reader supports.- Specified by:
getReadableMediaTypesin interfaceHttpMessageReader<MultiValueMap<String,String>>