public class HttpPostRequestDecoder extends java.lang.Object implements InterfaceHttpPostRequestDecoder
| Modifier and Type | Class and Description |
|---|---|
static class |
HttpPostRequestDecoder.EndOfDataDecoderException
Exception when the body is fully decoded, even if there is still data
|
static class |
HttpPostRequestDecoder.ErrorDataDecoderException
Exception when an error occurs while decoding
|
protected static class |
HttpPostRequestDecoder.MultiPartStatus
states follow
NOTSTARTED PREAMBLE (
(HEADERDELIMITER DISPOSITION (FIELD | FILEUPLOAD))*
(HEADERDELIMITER DISPOSITION MIXEDPREAMBLE
(MIXEDDELIMITER MIXEDDISPOSITION MIXEDFILEUPLOAD)+
MIXEDCLOSEDELIMITER)*
CLOSEDELIMITER)+ EPILOGUE
First status 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
...
|
static class |
HttpPostRequestDecoder.NotEnoughDataDecoderException
Exception when try reading data from request in chunked format, and not enough
data are available (need more chunks)
|
| Modifier and Type | Field and Description |
|---|---|
private InterfaceHttpPostRequestDecoder |
decoder
Does this request is a Multipart request
|
| Constructor and Description |
|---|
HttpPostRequestDecoder(HttpDataFactory factory,
HttpRequest request) |
HttpPostRequestDecoder(HttpDataFactory factory,
HttpRequest request,
java.nio.charset.Charset charset) |
HttpPostRequestDecoder(HttpRequest request) |
| Modifier and Type | Method and Description |
|---|---|
void |
cleanFiles()
Clean all HttpDatas (on Disk) for the current request.
|
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. |
protected static java.lang.String[] |
getMultipartDataBoundary(java.lang.String contentType)
Check from the request ContentType if this request is a Multipart request.
|
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
|
static boolean |
isMultipart(HttpRequest request)
Check if the given request is 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
|
void |
removeHttpDataFromClean(InterfaceHttpData data)
Remove the given FileUpload from the list of FileUploads to clean
|
private static java.lang.String[] |
splitHeaderContentType(java.lang.String sb)
Split the very first line (Content-Type value) in 3 Strings
|
private final InterfaceHttpPostRequestDecoder decoder
public HttpPostRequestDecoder(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 HttpPostRequestDecoder(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 HttpPostRequestDecoder(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 errorspublic static boolean isMultipart(HttpRequest request) throws HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.ErrorDataDecoderExceptionprotected static java.lang.String[] getMultipartDataBoundary(java.lang.String contentType)
throws HttpPostRequestDecoder.ErrorDataDecoderException
HttpPostRequestDecoder.ErrorDataDecoderExceptionpublic boolean isMultipart()
isMultipart in interface InterfaceHttpPostRequestDecoderpublic java.util.List<InterfaceHttpData> getBodyHttpDatas() throws HttpPostRequestDecoder.NotEnoughDataDecoderException
getBodyHttpDatas in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.NotEnoughDataDecoderException - Need more chunkspublic java.util.List<InterfaceHttpData> getBodyHttpDatas(java.lang.String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException
getBodyHttpDatas in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.NotEnoughDataDecoderException - need more chunkspublic InterfaceHttpData getBodyHttpData(java.lang.String name) throws HttpPostRequestDecoder.NotEnoughDataDecoderException
getBodyHttpData in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.NotEnoughDataDecoderException - need more chunkspublic void offer(HttpChunk chunk) throws HttpPostRequestDecoder.ErrorDataDecoderException
offer 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
hasNext in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.EndOfDataDecoderException - No more data will be availablepublic InterfaceHttpData next() throws HttpPostRequestDecoder.EndOfDataDecoderException
next in interface InterfaceHttpPostRequestDecoderHttpPostRequestDecoder.EndOfDataDecoderException - No more data will be availablepublic void cleanFiles()
cleanFiles in interface InterfaceHttpPostRequestDecoderpublic void removeHttpDataFromClean(InterfaceHttpData data)
removeHttpDataFromClean in interface InterfaceHttpPostRequestDecoderprivate static java.lang.String[] splitHeaderContentType(java.lang.String sb)