Top Description Inners Fields Constructors Methods
io.netty.contrib.handler.codec.http.multipart

public Class HttpPostRequestDecoder

extends Object
implements InterfaceHttpPostRequestDecoder
Class Inheritance
All Implemented Interfaces
io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder
Imports
io.netty5.util.internal.ObjectUtil, .StringUtil, io.netty5.handler.codec.DecoderException, io.netty5.handler.codec.http.HttpConstants, .HttpContent, .HttpHeaderNames, .HttpHeaderValues, .HttpRequest, java.nio.charset.Charset, java.util.List

This decoder will decode Body and can handle POST BODY. You MUST call destroy() after completion to release all resources.

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
HttpPostRequestDecoder.EndOfDataDecoderException

Exception when the body is fully decoded, even if there is still data

public static class
HttpPostRequestDecoder.ErrorDataDecoderException

Exception when an error occurs while decoding

protected static enum
HttpPostRequestDecoder.MultiPartStatus

states follow NOTSTARTED PREAMBLE ( (HEADERDELIMITER DISPOSITION (FIELD |
FILEUPLOAD))* (HEADERDELIMITER DISPOSITION MIXEDPREAMBLE (MIXEDDELIMITER
MIXEDDISPOSITION MIXEDFILEUPLOAD)+ MIXEDCLOSEDELIMITER)* CLOSEDELIMITER)+
EPILOGUE

First getStatus is: NOSTARTED

Content-type: multipart/form-data, boundary=AaB03x => PREAMBLE in Header

--AaB03x => HEADERDELIMITER content-disposition: form-data; name="field1"
=> DISPOSITION

Joe Blow => FIELD --AaB03x => HEADERDELIMITER content-disposition:
form-data; name="pics" => DISPOSITION Content-type: multipart/mixed,
boundary=BbC04y

--BbC04y => MIXEDDELIMITER Content-disposition: attachment;
filename="file1.txt" => MIXEDDISPOSITION Content-Type: text/plain

...
public static class
HttpPostRequestDecoder.NotEnoughDataDecoderException

Exception when try reading data from request in chunked format, and not enough data are available (need more chunks)

Field Summary

Modifier and TypeField and Description
private final InterfaceHttpPostRequestDecoder
pack-priv static final int

Constructor Summary

AccessConstructor and Description
public
HttpPostRequestDecoder(HttpRequest
the request to decode
request
)

public
HttpPostRequestDecoder(HttpDataFactory
the factory used to create InterfaceHttpData
factory
,
HttpRequest
the request to decode
request
)

public
HttpPostRequestDecoder(HttpDataFactory
the factory used to create InterfaceHttpData
factory
,
HttpRequest
the request to decode
request
,
Charset
the charset to use as default
charset
)

Method Summary

Modifier and TypeMethod and Description
public void
cleanFiles()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.cleanFiles.

Clean all HttpDatas (on Disk) for the current request.
public InterfaceHttpData
currentPartialHttpData()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.currentPartialHttpData.

Returns the current InterfaceHttpData if currently in decoding status, meaning all data are not yet within, or null if there is no InterfaceHttpData currently in decoding status (either because none yet decoded or none currently partially decoded).
public void
public InterfaceHttpData
getBodyHttpData(String name)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpData.

This getMethod returns the first InterfaceHttpData with the given name from body.
public List<InterfaceHttpData>
public List<InterfaceHttpData>
getBodyHttpDatas(String name)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpDatas.

This getMethod returns a List of all HttpDatas with the given name from body.
public int
getDiscardThreshold()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getDiscardThreshold.

Return the threshold in bytes after which read data in the buffer should be discarded.
protected static String[]

Returns:

an array of String if multipartDataBoundary exists with the multipartDataBoundary as first element, charset if any as second (missing if not set), else null
getMultipartDataBoundary
(String contentType)

Check from the request ContentType if this request is a Multipart request.

public boolean
hasNext()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.hasNext.

True if at current getStatus, there is an available decoded InterfaceHttpData from the Body.
public static boolean

Returns:

True if the request is a Multipart request
isMultipart
(HttpRequest request)

Check if the given request is a multipart request

public boolean
public InterfaceHttpData
next()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.next.

Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more available InterfaceHttpData.
public InterfaceHttpPostRequestDecoder
offer(HttpContent<?>
the new received chunk
content
)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.offer.

Initialized the internals from a new chunk
public void
public void
setDiscardThreshold(int discardThreshold)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.setDiscardThreshold.

Set the amount of bytes after which read bytes in the buffer should be discarded.
private static String[]

Returns:

the array of 3 Strings
splitHeaderContentType
(String sb)

Split the very first line (Content-Type value) in 3 Strings

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

decoderback to summary
private final InterfaceHttpPostRequestDecoder decoder
DEFAULT_DISCARD_THRESHOLDback to summary
pack-priv static final int DEFAULT_DISCARD_THRESHOLD

Constructor Detail

HttpPostRequestDecoderback to summary
public HttpPostRequestDecoder(HttpRequest request)
Parameters
request:HttpRequest

the request to decode

Exceptions
NullPointerException:
for request
ErrorDataDecoderException:
if the default charset was wrong when decoding or other errors
HttpPostRequestDecoderback to summary
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request)
Parameters
factory:HttpDataFactory

the factory used to create InterfaceHttpData

request:HttpRequest

the request to decode

Exceptions
NullPointerException:
for request or factory
ErrorDataDecoderException:
if the default charset was wrong when decoding or other errors
HttpPostRequestDecoderback to summary
public HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset)
Parameters
factory:HttpDataFactory

the factory used to create InterfaceHttpData

request:HttpRequest

the request to decode

charset:Charset

the charset to use as default

Exceptions
NullPointerException:
for request or charset or factory
ErrorDataDecoderException:
if the default charset was wrong when decoding or other errors

Method Detail

cleanFilesback to summary
public void cleanFiles()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.cleanFiles.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.cleanFiles.

Clean all HttpDatas (on Disk) for the current request.

Annotations
@Override
currentPartialHttpDataback to summary
public InterfaceHttpData currentPartialHttpData()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.currentPartialHttpData.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.currentPartialHttpData.

Returns the current InterfaceHttpData if currently in decoding status, meaning all data are not yet within, or null if there is no InterfaceHttpData currently in decoding status (either because none yet decoded or none currently partially decoded). Full decoded ones are accessible through hasNext() and next() methods.

Returns:InterfaceHttpData

the current InterfaceHttpData if currently in decoding status or null if none.

Annotations
@Override
destroyback to summary
public void destroy()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.destroy.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.destroy.

Destroy the InterfaceHttpPostRequestDecoder and release all it resources. After this method was called it is not possible to operate on it anymore.

Annotations
@Override
getBodyHttpDataback to summary
public InterfaceHttpData getBodyHttpData(String name)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpData.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpData.

This getMethod returns the first InterfaceHttpData with the given name from body.
If chunked, all chunks must have been offered using offer() getMethod. If not, NotEnoughDataDecoderException will be raised.

Returns:InterfaceHttpData

The first Body InterfaceHttpData with the given name (ignore case)

Annotations
@Override
getBodyHttpDatasback to summary
public List<InterfaceHttpData> getBodyHttpDatas()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpDatas.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpDatas.

This getMethod returns a List of all HttpDatas from body.
If chunked, all chunks must have been offered using offer() getMethod. If not, NotEnoughDataDecoderException will be raised.

Returns:List<InterfaceHttpData>

the list of HttpDatas from Body part for POST getMethod

Annotations
@Override
getBodyHttpDatasback to summary
public List<InterfaceHttpData> getBodyHttpDatas(String name)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpDatas.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getBodyHttpDatas.

This getMethod returns a List of all HttpDatas with the given name from body.
If chunked, all chunks must have been offered using offer() getMethod. If not, NotEnoughDataDecoderException will be raised.

Returns:List<InterfaceHttpData>

All Body HttpDatas with the given name (ignore case)

Annotations
@Override
getDiscardThresholdback to summary
public int getDiscardThreshold()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getDiscardThreshold.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.getDiscardThreshold.

Return the threshold in bytes after which read data in the buffer should be discarded.

Annotations
@Override
getMultipartDataBoundaryback to summary
protected static String[] getMultipartDataBoundary(String contentType)

Check from the request ContentType if this request is a Multipart request.

Returns:String[]

an array of String if multipartDataBoundary exists with the multipartDataBoundary as first element, charset if any as second (missing if not set), else null

hasNextback to summary
public boolean hasNext()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.hasNext.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.hasNext.

True if at current getStatus, there is an available decoded InterfaceHttpData from the Body. This getMethod works for chunked and not chunked request.

Returns:boolean

True if at current getStatus, there is a decoded InterfaceHttpData

Annotations
@Override
isMultipartback to summary
public static boolean isMultipart(HttpRequest request)

Check if the given request is a multipart request

Returns:boolean

True if the request is a Multipart request

isMultipartback to summary
public boolean isMultipart()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.isMultipart.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.isMultipart.

True if this request is a Multipart request

Returns:boolean

True if this request is a Multipart request

Annotations
@Override
nextback to summary
public InterfaceHttpData next()

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.next.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.next.

Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more available InterfaceHttpData. A subsequent call to offer(httpChunk) could enable more data. Be sure to call InterfaceHttpData#close() after you are done with processing to make sure to not leak any resources

Returns:InterfaceHttpData

the next available InterfaceHttpData or null if none

Annotations
@Override
offerback to summary
public InterfaceHttpPostRequestDecoder offer(HttpContent<?> content)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.offer.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.offer.

Initialized the internals from a new chunk

Parameters
content:HttpContent<?>

the new received chunk

Annotations
@Override
removeHttpDataFromCleanback to summary
public void removeHttpDataFromClean(InterfaceHttpData data)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.removeHttpDataFromClean.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.removeHttpDataFromClean.

Remove the given FileUpload from the list of FileUploads to clean

Annotations
@Override
setDiscardThresholdback to summary
public void setDiscardThreshold(int discardThreshold)

Implements io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.setDiscardThreshold.

Doc from io.netty.contrib.handler.codec.http.multipart.InterfaceHttpPostRequestDecoder.setDiscardThreshold.

Set the amount of bytes after which read bytes in the buffer should be discarded. Setting this lower gives lower memory usage but with the overhead of more memory copies. Use 0 to disable it.

Annotations
@Override
splitHeaderContentTypeback to summary
private static String[] splitHeaderContentType(String sb)

Split the very first line (Content-Type value) in 3 Strings

Returns:String[]

the array of 3 Strings

io.netty.contrib.handler.codec.http.multipart back to summary

public Class HttpPostRequestDecoder.EndOfDataDecoderException

extends DecoderException
Class Inheritance

Exception when the body is fully decoded, even if there is still data

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides io.netty5.handler.codec.DecoderException.serialVersionUID.

Constructor Detail

EndOfDataDecoderExceptionback to summary
public EndOfDataDecoderException()
io.netty.contrib.handler.codec.http.multipart back to summary

public Class HttpPostRequestDecoder.ErrorDataDecoderException

extends DecoderException
Class Inheritance

Exception when an error occurs while decoding

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public
public
public
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides io.netty5.handler.codec.DecoderException.serialVersionUID.

Constructor Detail

ErrorDataDecoderExceptionback to summary
public ErrorDataDecoderException()
ErrorDataDecoderExceptionback to summary
public ErrorDataDecoderException(String msg)
ErrorDataDecoderExceptionback to summary
public ErrorDataDecoderException(Throwable cause)
ErrorDataDecoderExceptionback to summary
public ErrorDataDecoderException(String msg, Throwable cause)
io.netty.contrib.handler.codec.http.multipart back to summary

protected final Enum HttpPostRequestDecoder.MultiPartStatus

extends Enum<HttpPostRequestDecoder.MultiPartStatus>
Class Inheritance

states follow NOTSTARTED PREAMBLE ( (HEADERDELIMITER DISPOSITION (FIELD |
FILEUPLOAD))* (HEADERDELIMITER DISPOSITION MIXEDPREAMBLE (MIXEDDELIMITER
MIXEDDISPOSITION MIXEDFILEUPLOAD)+ MIXEDCLOSEDELIMITER)* CLOSEDELIMITER)+
EPILOGUE

First getStatus is: NOSTARTED

Content-type: multipart/form-data, boundary=AaB03x => PREAMBLE in Header

--AaB03x => HEADERDELIMITER content-disposition: form-data; name="field1"
=> DISPOSITION

Joe Blow => FIELD --AaB03x => HEADERDELIMITER content-disposition:
form-data; name="pics" => DISPOSITION Content-type: multipart/mixed,
boundary=BbC04y

--BbC04y => MIXEDDELIMITER Content-disposition: attachment;
filename="file1.txt" => MIXEDDISPOSITION Content-Type: text/plain

... contents of file1.txt ... => MIXEDFILEUPLOAD --BbC04y =>
MIXEDDELIMITER Content-disposition: file; filename="file2.gif" =>
MIXEDDISPOSITION Content-type: image/gif Content-Transfer-Encoding:
binary

...contents of file2.gif... => MIXEDFILEUPLOAD --BbC04y-- =>
MIXEDCLOSEDELIMITER --AaB03x-- => CLOSEDELIMITER

Once CLOSEDELIMITER is found, last getStatus is EPILOGUE
 

Field Summary

Modifier and TypeField and Description
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus
public static final HttpPostRequestDecoder.MultiPartStatus

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static HttpPostRequestDecoder.MultiPartStatus
public static HttpPostRequestDecoder.MultiPartStatus[]
Inherited from java.lang.Enum:
clonecompareTodescribeConstableequalsfinalizegetDeclaringClasshashCodenameordinaltoStringvalueOf

Field Detail

CLOSEDELIMITERback to summary
public static final HttpPostRequestDecoder.MultiPartStatus CLOSEDELIMITER
DISPOSITIONback to summary
public static final HttpPostRequestDecoder.MultiPartStatus DISPOSITION
EPILOGUEback to summary
public static final HttpPostRequestDecoder.MultiPartStatus EPILOGUE
FIELDback to summary
public static final HttpPostRequestDecoder.MultiPartStatus FIELD
FILEUPLOADback to summary
public static final HttpPostRequestDecoder.MultiPartStatus FILEUPLOAD
HEADERDELIMITERback to summary
public static final HttpPostRequestDecoder.MultiPartStatus HEADERDELIMITER
MIXEDCLOSEDELIMITERback to summary
public static final HttpPostRequestDecoder.MultiPartStatus MIXEDCLOSEDELIMITER
MIXEDDELIMITERback to summary
public static final HttpPostRequestDecoder.MultiPartStatus MIXEDDELIMITER
MIXEDDISPOSITIONback to summary
public static final HttpPostRequestDecoder.MultiPartStatus MIXEDDISPOSITION
MIXEDFILEUPLOADback to summary
public static final HttpPostRequestDecoder.MultiPartStatus MIXEDFILEUPLOAD
MIXEDPREAMBLEback to summary
public static final HttpPostRequestDecoder.MultiPartStatus MIXEDPREAMBLE
NOTSTARTEDback to summary
public static final HttpPostRequestDecoder.MultiPartStatus NOTSTARTED
PREAMBLEback to summary
public static final HttpPostRequestDecoder.MultiPartStatus PREAMBLE
PREEPILOGUEback to summary
public static final HttpPostRequestDecoder.MultiPartStatus PREEPILOGUE

Constructor Detail

MultiPartStatusback to summary
private MultiPartStatus()

Method Detail

valueOfback to summary
public static HttpPostRequestDecoder.MultiPartStatus valueOf(String name)
valuesback to summary
public static HttpPostRequestDecoder.MultiPartStatus[] values()
io.netty.contrib.handler.codec.http.multipart back to summary

public Class HttpPostRequestDecoder.NotEnoughDataDecoderException

extends DecoderException
Class Inheritance

Exception when try reading data from request in chunked format, and not enough data are available (need more chunks)

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public
public
public
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides io.netty5.handler.codec.DecoderException.serialVersionUID.

Constructor Detail

NotEnoughDataDecoderExceptionback to summary
public NotEnoughDataDecoderException()
NotEnoughDataDecoderExceptionback to summary
public NotEnoughDataDecoderException(String msg)
NotEnoughDataDecoderExceptionback to summary
public NotEnoughDataDecoderException(Throwable cause)
NotEnoughDataDecoderExceptionback to summary
public NotEnoughDataDecoderException(String msg, Throwable cause)