Class HttpPostStandardRequestDecoder
- java.lang.Object
-
- org.jboss.netty.handler.codec.http.multipart.HttpPostStandardRequestDecoder
-
- All Implemented Interfaces:
InterfaceHttpPostRequestDecoder
public class HttpPostStandardRequestDecoder extends java.lang.Object implements InterfaceHttpPostRequestDecoder
This decoder will decode Body and can handle standard (non multipart) POST BODY.
-
-
Field Summary
Fields Modifier and Type Field Description private java.util.List<InterfaceHttpData>
bodyListHttpData
HttpDatas from Bodyprivate int
bodyListHttpDataRank
Body HttpDatas current positionprivate java.util.Map<java.lang.String,java.util.List<InterfaceHttpData>>
bodyMapHttpData
HttpDatas as Map from Bodyprivate java.nio.charset.Charset
charset
Default charset to useprivate Attribute
currentAttribute
The current Attribute that is currently in decode processprivate HttpPostRequestDecoder.MultiPartStatus
currentStatus
Current statusprivate HttpDataFactory
factory
Factory used to create InterfaceHttpDataprivate boolean
isLastChunk
Does the last chunk already receivedprivate int
maxBufferedBytes
The maximum number of accumulated bytes when decoding a fieldprivate int
maxFields
The maximum number of fields allows by the formprivate HttpRequest
request
Request to decodeprivate ChannelBuffer
undecodedChunk
The current channelBuffer
-
Constructor Summary
Constructors Constructor Description HttpPostStandardRequestDecoder(HttpRequest request)
HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request)
HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, java.nio.charset.Charset charset)
HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, java.nio.charset.Charset charset, int maxFields, int maxBufferedBytes)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description private void
addHttpData(InterfaceHttpData data)
Utility function to add a new decoded datavoid
cleanFiles()
Clean all HttpDatas (on Disk) for the current request.private static java.lang.String
decodeAttribute(java.lang.String s, java.nio.charset.Charset charset)
Decode componentInterfaceHttpData
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.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 requestInterfaceHttpData
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 chunkprivate void
parseBody()
This method will parse as much as possible data and fill the list and mapprivate void
parseBodyAttributes()
This method fill the map and list with as much Attribute as possible from Body in not Multipart mode.private void
parseBodyAttributesStandard()
This method fill the map and list with as much Attribute as possible from Body in not Multipart mode.void
removeHttpDataFromClean(InterfaceHttpData data)
Remove the given FileUpload from the list of FileUploads to cleanprivate void
setFinalBuffer(ChannelBuffer buffer)
-
-
-
Field Detail
-
factory
private final HttpDataFactory factory
Factory used to create InterfaceHttpData
-
request
private final HttpRequest request
Request to decode
-
charset
private final java.nio.charset.Charset charset
Default charset to use
-
maxFields
private final int maxFields
The maximum number of fields allows by the form
-
maxBufferedBytes
private final int maxBufferedBytes
The maximum number of accumulated bytes when decoding a field
-
isLastChunk
private boolean isLastChunk
Does the last chunk already received
-
bodyListHttpData
private final java.util.List<InterfaceHttpData> bodyListHttpData
HttpDatas from Body
-
bodyMapHttpData
private final java.util.Map<java.lang.String,java.util.List<InterfaceHttpData>> bodyMapHttpData
HttpDatas as Map from Body
-
undecodedChunk
private ChannelBuffer undecodedChunk
The current channelBuffer
-
bodyListHttpDataRank
private int bodyListHttpDataRank
Body HttpDatas current position
-
currentStatus
private HttpPostRequestDecoder.MultiPartStatus currentStatus
Current status
-
currentAttribute
private Attribute currentAttribute
The current Attribute that is currently in decode process
-
-
Constructor Detail
-
HttpPostStandardRequestDecoder
public HttpPostStandardRequestDecoder(HttpRequest request) throws HttpPostRequestDecoder.ErrorDataDecoderException
- Parameters:
request
- the request to decode- Throws:
java.lang.NullPointerException
- for requestHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other errors
-
HttpPostStandardRequestDecoder
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request) throws HttpPostRequestDecoder.ErrorDataDecoderException
- Parameters:
factory
- the factory used to create InterfaceHttpDatarequest
- the request to decode- Throws:
java.lang.NullPointerException
- for request or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other errors
-
HttpPostStandardRequestDecoder
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, java.nio.charset.Charset charset) throws HttpPostRequestDecoder.ErrorDataDecoderException
- Parameters:
factory
- the factory used to create InterfaceHttpDatarequest
- the request to decodecharset
- the charset to use as default- Throws:
java.lang.NullPointerException
- for request or charset or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other errors
-
HttpPostStandardRequestDecoder
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, java.nio.charset.Charset charset, int maxFields, int maxBufferedBytes) throws HttpPostRequestDecoder.ErrorDataDecoderException
- Parameters:
factory
- the factory used to create InterfaceHttpDatarequest
- the request to decodecharset
- the charset to use as defaultmaxFields
- the maximum number of fields the form can have,-1
to disablemaxBufferedBytes
- the maximum number of bytes the decoder can buffer when decoding a field,-1
to disable- Throws:
java.lang.NullPointerException
- for request or charset or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other errors
-
-
Method Detail
-
isMultipart
public boolean isMultipart()
Description copied from interface:InterfaceHttpPostRequestDecoder
True if this request is a Multipart request- Specified by:
isMultipart
in interfaceInterfaceHttpPostRequestDecoder
- Returns:
- True if this request is a Multipart request
-
getBodyHttpDatas
public java.util.List<InterfaceHttpData> getBodyHttpDatas() throws HttpPostRequestDecoder.NotEnoughDataDecoderException
Description copied from interface:InterfaceHttpPostRequestDecoder
This method returns a List of all HttpDatas from body.
If chunked, all chunks must have been offered using offer() method. If not, NotEnoughDataDecoderException will be raised.- Specified by:
getBodyHttpDatas
in interfaceInterfaceHttpPostRequestDecoder
- Returns:
- the list of HttpDatas from Body part for POST method
- Throws:
HttpPostRequestDecoder.NotEnoughDataDecoderException
- Need more chunks
-
getBodyHttpDatas
public java.util.List<InterfaceHttpData> getBodyHttpDatas(java.lang.String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException
Description copied from interface:InterfaceHttpPostRequestDecoder
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. If not, NotEnoughDataDecoderException will be raised.- Specified by:
getBodyHttpDatas
in interfaceInterfaceHttpPostRequestDecoder
- Returns:
- All Body HttpDatas with the given name (ignore case)
- Throws:
HttpPostRequestDecoder.NotEnoughDataDecoderException
- need more chunks
-
getBodyHttpData
public InterfaceHttpData getBodyHttpData(java.lang.String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException
Description copied from interface:InterfaceHttpPostRequestDecoder
This method returns the first InterfaceHttpData with the given name from body.
If chunked, all chunks must have been offered using offer() method. If not, NotEnoughDataDecoderException will be raised.- Specified by:
getBodyHttpData
in interfaceInterfaceHttpPostRequestDecoder
- Returns:
- The first Body InterfaceHttpData with the given name (ignore case)
- Throws:
HttpPostRequestDecoder.NotEnoughDataDecoderException
- need more chunks
-
offer
public void offer(HttpChunk chunk) throws HttpPostRequestDecoder.ErrorDataDecoderException
Description copied from interface:InterfaceHttpPostRequestDecoder
Initialized the internals from a new chunk- Specified by:
offer
in interfaceInterfaceHttpPostRequestDecoder
- Parameters:
chunk
- the new received chunk- Throws:
HttpPostRequestDecoder.ErrorDataDecoderException
- if there is a problem with the charset decoding or other errors
-
hasNext
public boolean hasNext() throws HttpPostRequestDecoder.EndOfDataDecoderException
Description copied from interface:InterfaceHttpPostRequestDecoder
True if at current status, there is an available decoded InterfaceHttpData from the Body. This method works for chunked and not chunked request.- Specified by:
hasNext
in interfaceInterfaceHttpPostRequestDecoder
- Returns:
- True if at current status, there is a decoded InterfaceHttpData
- Throws:
HttpPostRequestDecoder.EndOfDataDecoderException
- No more data will be available
-
next
public InterfaceHttpData next() throws HttpPostRequestDecoder.EndOfDataDecoderException
Description copied from interface:InterfaceHttpPostRequestDecoder
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.- Specified by:
next
in interfaceInterfaceHttpPostRequestDecoder
- Returns:
- the next available InterfaceHttpData or null if none
- Throws:
HttpPostRequestDecoder.EndOfDataDecoderException
- No more data will be available
-
parseBody
private void parseBody() throws HttpPostRequestDecoder.ErrorDataDecoderException
This method will parse as much as possible data and fill the list and map- Throws:
HttpPostRequestDecoder.ErrorDataDecoderException
- if there is a problem with the charset decoding or other errors
-
addHttpData
private void addHttpData(InterfaceHttpData data) throws HttpPostRequestDecoder.ErrorDataDecoderException
Utility function to add a new decoded data
-
parseBodyAttributesStandard
private void parseBodyAttributesStandard() throws HttpPostRequestDecoder.ErrorDataDecoderException
This method fill the map and list with as much Attribute as possible from Body in not Multipart mode.- Throws:
HttpPostRequestDecoder.ErrorDataDecoderException
- if there is a problem with the charset decoding or other errors
-
parseBodyAttributes
private void parseBodyAttributes() throws HttpPostRequestDecoder.ErrorDataDecoderException
This method fill the map and list with as much Attribute as possible from Body in not Multipart mode.- Throws:
HttpPostRequestDecoder.ErrorDataDecoderException
- if there is a problem with the charset decoding or other errors
-
setFinalBuffer
private void setFinalBuffer(ChannelBuffer buffer) throws HttpPostRequestDecoder.ErrorDataDecoderException, java.io.IOException
- Throws:
HttpPostRequestDecoder.ErrorDataDecoderException
java.io.IOException
-
decodeAttribute
private static java.lang.String decodeAttribute(java.lang.String s, java.nio.charset.Charset charset) throws HttpPostRequestDecoder.ErrorDataDecoderException
Decode component- Returns:
- the decoded component
- Throws:
HttpPostRequestDecoder.ErrorDataDecoderException
-
cleanFiles
public void cleanFiles()
Description copied from interface:InterfaceHttpPostRequestDecoder
Clean all HttpDatas (on Disk) for the current request.- Specified by:
cleanFiles
in interfaceInterfaceHttpPostRequestDecoder
-
removeHttpDataFromClean
public void removeHttpDataFromClean(InterfaceHttpData data)
Description copied from interface:InterfaceHttpPostRequestDecoder
Remove the given FileUpload from the list of FileUploads to clean- Specified by:
removeHttpDataFromClean
in interfaceInterfaceHttpPostRequestDecoder
-
-