public class HttpPostMultipartRequestDecoder extends java.lang.Object implements InterfaceHttpPostRequestDecoder
| Modifier and Type | Field and Description |
|---|---|
private java.util.List<InterfaceHttpData> |
bodyListHttpData
HttpDatas from Body
|
private int |
bodyListHttpDataRank
Body HttpDatas current position
|
private java.util.Map<java.lang.String,java.util.List<InterfaceHttpData>> |
bodyMapHttpData
HttpDatas as Map from Body
|
private java.nio.charset.Charset |
charset
Default charset to use
|
private Attribute |
currentAttribute
The current Attribute that is currently in decode process
|
private java.util.Map<java.lang.String,Attribute> |
currentFieldAttributes
Used in Multipart
|
private FileUpload |
currentFileUpload
The current FileUpload that is currently in decode process
|
private HttpPostRequestDecoder.MultiPartStatus |
currentStatus
Current status
|
private HttpDataFactory |
factory
Factory used to create InterfaceHttpData
|
private boolean |
isLastChunk
Does the last chunk already received
|
private java.lang.String |
multipartDataBoundary
If multipart, this is the boundary for the flobal multipart
|
private java.lang.String |
multipartMixedBoundary
If multipart, there could be internal multiparts (mixed) to the global multipart.
|
private HttpRequest |
request
Request to decode
|
private ChannelBuffer |
undecodedChunk
The current channelBuffer
|
| Constructor and Description |
|---|
HttpPostMultipartRequestDecoder(HttpDataFactory factory,
HttpRequest request) |
HttpPostMultipartRequestDecoder(HttpDataFactory factory,
HttpRequest request,
java.nio.charset.Charset charset) |
HttpPostMultipartRequestDecoder(HttpRequest request) |
| Modifier and Type | Method and Description |
|---|---|
private void |
addHttpData(InterfaceHttpData data)
Utility function to add a new decoded data
|
void |
cleanFiles()
Clean all HttpDatas (on Disk) for the current request.
|
private void |
cleanMixedAttributes()
Remove all Attributes that should be cleaned between two FileUpload in Mixed mode
|
private static java.lang.String |
cleanString(java.lang.String field)
Clean the String from any unallowed character
|
private InterfaceHttpData |
decodeMultipart(HttpPostRequestDecoder.MultiPartStatus state)
Decode a multipart request by pieces
NOTSTARTED PREAMBLE ( (HEADERDELIMITER DISPOSITION (FIELD | FILEUPLOAD))* (HEADERDELIMITER DISPOSITION MIXEDPREAMBLE (MIXEDDELIMITER MIXEDDISPOSITION MIXEDFILEUPLOAD)+ MIXEDCLOSEDELIMITER)* CLOSEDELIMITER)+ EPILOGUE Inspired from HttpMessageDecoder |
private InterfaceHttpData |
findMultipartDelimiter(java.lang.String delimiter,
HttpPostRequestDecoder.MultiPartStatus dispositionStatus,
HttpPostRequestDecoder.MultiPartStatus closeDelimiterStatus)
Find the next Multipart Delimiter
|
private InterfaceHttpData |
findMultipartDisposition()
Find the next Disposition
|
InterfaceHttpData |
getBodyHttpData(java.lang.String name)
This method returns the first InterfaceHttpData with the given name from body.
If chunked, all chunks must have been offered using offer() method. |
java.util.List<InterfaceHttpData> |
getBodyHttpDatas()
This method returns a List of all HttpDatas from body.
If chunked, all chunks must have been offered using offer() method. |
java.util.List<InterfaceHttpData> |
getBodyHttpDatas(java.lang.String name)
This method returns a List of all HttpDatas with the given name from body.
If chunked, all chunks must have been offered using offer() method. |
private InterfaceHttpData |
getFileUpload(java.lang.String delimiter)
Get the FileUpload (new one or current one)
|
boolean |
hasNext()
True if at current status, there is an available decoded InterfaceHttpData from the Body.
|
boolean |
isMultipart()
True if this request is a Multipart request
|
private void |
loadFieldMultipart(java.lang.String delimiter)
Load the field value from a Multipart request
|
private void |
loadFieldMultipartStandard(java.lang.String delimiter)
Load the field value from a Multipart request
|
InterfaceHttpData |
next()
Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more
available InterfaceHttpData.
|
void |
offer(HttpChunk chunk)
Initialized the internals from a new chunk
|
private void |
parseBody()
This method will parse as much as possible data and fill the list and map
|
private void |
parseBodyMultipart()
Parse the Body for multipart
|
private java.lang.String |
readDelimiter(java.lang.String delimiter)
Read one line up to --delimiter or --delimiter-- and if existing the CRLF or LF.
|
private java.lang.String |
readDelimiterStandard(java.lang.String delimiter)
Read one line up to --delimiter or --delimiter-- and if existing the CRLF or LF
Read one line up to --delimiter or --delimiter-- and if existing the CRLF or LF.
|
private void |
readFileUploadByteMultipart(java.lang.String delimiter)
Read a FileUpload data as Byte (Binary) and add the bytes directly to the
FileUpload.
|
private void |
readFileUploadByteMultipartStandard(java.lang.String delimiter)
Read a FileUpload data as Byte (Binary) and add the bytes directly to the
FileUpload.
|
private java.lang.String |
readLine()
Read one line up to the CRLF or LF
|
private java.lang.String |
readLineStandard()
Read one line up to the CRLF or LF
|
void |
removeHttpDataFromClean(InterfaceHttpData data)
Remove the given FileUpload from the list of FileUploads to clean
|
private void |
setMultipart(java.lang.String contentType)
Set from the request ContentType the multipartDataBoundary and the possible charset.
|
(package private) void |
skipControlCharacters()
Skip control Characters
|
(package private) void |
skipControlCharactersStandard() |
private boolean |
skipOneLine()
Skip one empty line
|
private static java.lang.String[] |
splitMultipartHeader(java.lang.String sb)
Split one header in Multipart
|
private static java.lang.String[] |
splitMultipartHeaderValues(java.lang.String svalue)
Split one header value in Multipart.
|
private final HttpDataFactory factory
private final HttpRequest request
private java.nio.charset.Charset charset
private boolean isLastChunk
private final java.util.List<InterfaceHttpData> bodyListHttpData
private final java.util.Map<java.lang.String,java.util.List<InterfaceHttpData>> bodyMapHttpData
private ChannelBuffer undecodedChunk
private int bodyListHttpDataRank
private java.lang.String multipartDataBoundary
private java.lang.String multipartMixedBoundary
private HttpPostRequestDecoder.MultiPartStatus currentStatus
private java.util.Map<java.lang.String,Attribute> currentFieldAttributes
private FileUpload currentFileUpload
private Attribute currentAttribute
public HttpPostMultipartRequestDecoder(HttpRequest request) throws HttpPostRequestDecoder.ErrorDataDecoderException
request - the request to decodejava.lang.NullPointerException - for requestHttpPostRequestDecoder.ErrorDataDecoderException - if the default charset was wrong when decoding or other errorspublic HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request) throws HttpPostRequestDecoder.ErrorDataDecoderException
factory - the factory used to create InterfaceHttpDatarequest - the request to decodejava.lang.NullPointerException - for request or factoryHttpPostRequestDecoder.ErrorDataDecoderException - if the default charset was wrong when decoding or other errorspublic HttpPostMultipartRequestDecoder(HttpDataFactory factory, HttpRequest request, java.nio.charset.Charset charset) throws HttpPostRequestDecoder.ErrorDataDecoderException
factory - the factory used to create InterfaceHttpDatarequest - the request to decodecharset - the charset to use as defaultjava.lang.NullPointerException - for request or charset or factoryHttpPostRequestDecoder.ErrorDataDecoderException - if the default charset was wrong when decoding or other errorsprivate void setMultipart(java.lang.String contentType)
throws HttpPostRequestDecoder.ErrorDataDecoderException
public boolean isMultipart()
InterfaceHttpPostRequestDecoderisMultipart in interface InterfaceHttpPostRequestDecoderpublic java.util.List<InterfaceHttpData> getBodyHttpDatas() throws HttpPostRequestDecoder.NotEnoughDataDecoderException
InterfaceHttpPostRequestDecodergetBodyHttpDatas in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunkspublic java.util.List<InterfaceHttpData> getBodyHttpDatas(java.lang.String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException
InterfaceHttpPostRequestDecodergetBodyHttpDatas in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.NotEnoughDataDecoderException - need more chunkspublic InterfaceHttpData getBodyHttpData(java.lang.String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException
InterfaceHttpPostRequestDecodergetBodyHttpData in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.NotEnoughDataDecoderException - need more chunkspublic void offer(HttpChunk chunk) throws HttpPostRequestDecoder.ErrorDataDecoderException
InterfaceHttpPostRequestDecoderoffer in interface InterfaceHttpPostRequestDecoderchunk - the new received chunkHttpPostRequestDecoder.ErrorDataDecoderException - if there is a problem with the charset decoding or
other errorspublic boolean hasNext()
throws HttpPostRequestDecoder.EndOfDataDecoderException
InterfaceHttpPostRequestDecoderhasNext in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.EndOfDataDecoderException - No more data will be availablepublic InterfaceHttpData next() throws HttpPostRequestDecoder.EndOfDataDecoderException
InterfaceHttpPostRequestDecodernext in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.EndOfDataDecoderException - No more data will be availableprivate void parseBody()
throws HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.ErrorDataDecoderException - if there is a problem with the charset decoding or
other errorsprivate void addHttpData(InterfaceHttpData data)
private void parseBodyMultipart()
throws HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.ErrorDataDecoderException - if there is a problem with the charset decoding or other errorsprivate InterfaceHttpData decodeMultipart(HttpPostRequestDecoder.MultiPartStatus state) throws HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.ErrorDataDecoderException - if an error occursvoid skipControlCharacters()
throws HttpPostRequestDecoder.NotEnoughDataDecoderException
void skipControlCharactersStandard()
private InterfaceHttpData findMultipartDelimiter(java.lang.String delimiter, HttpPostRequestDecoder.MultiPartStatus dispositionStatus, HttpPostRequestDecoder.MultiPartStatus closeDelimiterStatus) throws HttpPostRequestDecoder.ErrorDataDecoderException
delimiter - delimiter to finddispositionStatus - the next status if the delimiter is a startcloseDelimiterStatus - the next status if the delimiter is a close delimiterHttpPostRequestDecoder.ErrorDataDecoderExceptionprivate InterfaceHttpData findMultipartDisposition() throws HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.ErrorDataDecoderExceptionprivate InterfaceHttpData getFileUpload(java.lang.String delimiter) throws HttpPostRequestDecoder.ErrorDataDecoderException
delimiter - the delimiter to useHttpPostRequestDecoder.ErrorDataDecoderExceptionpublic void cleanFiles()
InterfaceHttpPostRequestDecodercleanFiles in interface InterfaceHttpPostRequestDecoderpublic void removeHttpDataFromClean(InterfaceHttpData data)
InterfaceHttpPostRequestDecoderremoveHttpDataFromClean in interface InterfaceHttpPostRequestDecoderprivate void cleanMixedAttributes()
private java.lang.String readLineStandard()
throws HttpPostRequestDecoder.NotEnoughDataDecoderException
HttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunks and
reset the readerInder to the previous valueprivate java.lang.String readLine()
throws HttpPostRequestDecoder.NotEnoughDataDecoderException
HttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunks and
reset the readerInder to the previous valueprivate java.lang.String readDelimiterStandard(java.lang.String delimiter)
throws HttpPostRequestDecoder.NotEnoughDataDecoderException
delimiter - of the form --string, such that '--' is already includedHttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunks and
reset the readerInder to the previous valueprivate java.lang.String readDelimiter(java.lang.String delimiter)
throws HttpPostRequestDecoder.NotEnoughDataDecoderException
delimiter - of the form --string, such that '--' is already includedHttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunks and
reset the readerInder to the previous valueprivate void readFileUploadByteMultipartStandard(java.lang.String delimiter)
throws HttpPostRequestDecoder.NotEnoughDataDecoderException,
HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunks but
do not reset the readerInder since some values will be already added to the FileOutputHttpPostRequestDecoder.ErrorDataDecoderException - write IO error occurs with the FileUploadprivate void readFileUploadByteMultipart(java.lang.String delimiter)
throws HttpPostRequestDecoder.NotEnoughDataDecoderException,
HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunks but
do not reset the readerInder since some values will be already added to the FileOutputHttpPostRequestDecoder.ErrorDataDecoderException - write IO error occurs with the FileUploadprivate void loadFieldMultipartStandard(java.lang.String delimiter)
throws HttpPostRequestDecoder.NotEnoughDataDecoderException,
HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunksHttpPostRequestDecoder.ErrorDataDecoderExceptionprivate void loadFieldMultipart(java.lang.String delimiter)
throws HttpPostRequestDecoder.NotEnoughDataDecoderException,
HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunksHttpPostRequestDecoder.ErrorDataDecoderExceptionprivate static java.lang.String cleanString(java.lang.String field)
private boolean skipOneLine()
private static java.lang.String[] splitMultipartHeader(java.lang.String sb)
private static java.lang.String[] splitMultipartHeaderValues(java.lang.String svalue)
String where values that were separated by ';' or ','