Class HttpPostStandardRequestDecoder
java.lang.Object
org.jboss.netty.handler.codec.http.multipart.HttpPostStandardRequestDecoder
- All Implemented Interfaces:
InterfaceHttpPostRequestDecoder
public class HttpPostStandardRequestDecoder
extends Object
implements InterfaceHttpPostRequestDecoder
This decoder will decode Body and can handle standard (non multipart) POST BODY.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final List<InterfaceHttpData>
HttpDatas from Bodyprivate int
Body HttpDatas current positionprivate final Map<String,
List<InterfaceHttpData>> HttpDatas as Map from Bodyprivate final Charset
Default charset to useprivate Attribute
The current Attribute that is currently in decode processCurrent statusprivate final HttpDataFactory
Factory used to create InterfaceHttpDataprivate boolean
Does the last chunk already receivedprivate final HttpRequest
Request to decodeprivate ChannelBuffer
The current channelBuffer -
Constructor Summary
ConstructorsConstructorDescriptionHttpPostStandardRequestDecoder
(HttpDataFactory factory, HttpRequest request) HttpPostStandardRequestDecoder
(HttpDataFactory factory, HttpRequest request, Charset charset) -
Method Summary
Modifier and TypeMethodDescriptionprivate void
addHttpData
(InterfaceHttpData data) Utility function to add a new decoded datavoid
Clean all HttpDatas (on Disk) for the current request.private static String
decodeAttribute
(String s, Charset charset) Decode componentgetBodyHttpData
(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.This method returns a List of all HttpDatas from body.
If chunked, all chunks must have been offered using offer() method.getBodyHttpDatas
(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
True if this request is a Multipart requestnext()
Returns the next available InterfaceHttpData or null if, at the time it is called, there is no more available InterfaceHttpData.void
Initialized the internals from a new chunkprivate void
This method will parse as much as possible data and fill the list and mapprivate void
This method fill the map and list with as much Attribute as possible from Body in not Multipart mode.private void
This method fill the map and list with as much Attribute as possible from Body in not Multipart mode.void
Remove the given FileUpload from the list of FileUploads to cleanprivate void
setFinalBuffer
(ChannelBuffer buffer)
-
Field Details
-
factory
Factory used to create InterfaceHttpData -
request
Request to decode -
charset
Default charset to use -
isLastChunk
private boolean isLastChunkDoes the last chunk already received -
bodyListHttpData
HttpDatas from Body -
bodyMapHttpData
HttpDatas as Map from Body -
undecodedChunk
The current channelBuffer -
bodyListHttpDataRank
private int bodyListHttpDataRankBody HttpDatas current position -
currentStatus
Current status -
currentAttribute
The current Attribute that is currently in decode process
-
-
Constructor Details
-
HttpPostStandardRequestDecoder
public HttpPostStandardRequestDecoder(HttpRequest request) throws HttpPostRequestDecoder.ErrorDataDecoderException - Parameters:
request
- the request to decode- Throws:
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:
NullPointerException
- for request or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other errors
-
HttpPostStandardRequestDecoder
public HttpPostStandardRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset) throws HttpPostRequestDecoder.ErrorDataDecoderException - Parameters:
factory
- the factory used to create InterfaceHttpDatarequest
- the request to decodecharset
- the charset to use as default- Throws:
NullPointerException
- for request or charset or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other errors
-
-
Method Details
-
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 List<InterfaceHttpData> getBodyHttpDatas() throws HttpPostRequestDecoder.NotEnoughDataDecoderExceptionDescription 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 List<InterfaceHttpData> getBodyHttpDatas(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(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
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
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
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
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
Utility function to add a new decoded data -
parseBodyAttributesStandard
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
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, IOException -
decodeAttribute
private static String decodeAttribute(String s, 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
Description copied from interface:InterfaceHttpPostRequestDecoder
Remove the given FileUpload from the list of FileUploads to clean- Specified by:
removeHttpDataFromClean
in interfaceInterfaceHttpPostRequestDecoder
-