public class HttpPostRequestDecoder extends Object implements InterfaceHttpPostRequestDecoder
destroy()
after completion to release all resources.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 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
|
static class |
HttpPostRequestDecoder.NotEnoughDataDecoderException
Exception when try reading data from request in chunked format, and not
enough data are available (need more chunks)
|
static class |
HttpPostRequestDecoder.TooLongFormFieldException
Exception when a field content is too long
|
static class |
HttpPostRequestDecoder.TooManyFormFieldsException
Exception when the maximum number of fields for a given form is reached
|
Constructor and Description |
---|
HttpPostRequestDecoder(HttpDataFactory factory,
HttpRequest request) |
HttpPostRequestDecoder(HttpDataFactory factory,
HttpRequest request,
Charset charset) |
HttpPostRequestDecoder(HttpDataFactory factory,
HttpRequest request,
Charset charset,
int maxFields,
int maxBufferedBytes) |
HttpPostRequestDecoder(HttpRequest request) |
HttpPostRequestDecoder(HttpRequest request,
int maxFields,
int maxBufferedBytes) |
Modifier and Type | Method and Description |
---|---|
void |
cleanFiles()
Clean all HttpDatas (on Disk) for the current request.
|
InterfaceHttpData |
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).
|
void |
destroy()
Destroy the
InterfaceHttpPostRequestDecoder and release all it resources. |
InterfaceHttpData |
getBodyHttpData(String name)
This getMethod returns the first InterfaceHttpData with the given name from
body.
|
List<InterfaceHttpData> |
getBodyHttpDatas()
This getMethod returns a List of all HttpDatas from body.
|
List<InterfaceHttpData> |
getBodyHttpDatas(String name)
This getMethod returns a List of all HttpDatas with the given name from
body.
|
int |
getDiscardThreshold()
Return the threshold in bytes after which read data in the buffer should be discarded.
|
protected static String[] |
getMultipartDataBoundary(String contentType)
Check from the request ContentType if this request is a Multipart request.
|
boolean |
hasNext()
True if at current getStatus, 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.
|
InterfaceHttpPostRequestDecoder |
offer(HttpContent content)
Initialized the internals from a new chunk
|
void |
removeHttpDataFromClean(InterfaceHttpData data)
Remove the given FileUpload from the list of FileUploads to clean
|
void |
setDiscardThreshold(int discardThreshold)
Set the amount of bytes after which read bytes in the buffer should be discarded.
|
public HttpPostRequestDecoder(HttpRequest request)
request
- the request to decodeNullPointerException
- for requestHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other
errorspublic HttpPostRequestDecoder(HttpRequest request, int maxFields, int maxBufferedBytes)
request
- the request to decodemaxFields
- 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 disableNullPointerException
- for requestHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other
errorspublic HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request)
factory
- the factory used to create InterfaceHttpDatarequest
- the request to decodeNullPointerException
- for request or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other
errorspublic HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset)
factory
- the factory used to create InterfaceHttpDatarequest
- the request to decodecharset
- the charset to use as defaultNullPointerException
- for request or charset or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other
errorspublic HttpPostRequestDecoder(HttpDataFactory factory, HttpRequest request, Charset charset, int maxFields, int maxBufferedBytes)
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 disableNullPointerException
- for request or charset or factoryHttpPostRequestDecoder.ErrorDataDecoderException
- if the default charset was wrong when decoding or other
errorspublic static boolean isMultipart(HttpRequest request)
protected static String[] getMultipartDataBoundary(String contentType)
public boolean isMultipart()
InterfaceHttpPostRequestDecoder
isMultipart
in interface InterfaceHttpPostRequestDecoder
public void setDiscardThreshold(int discardThreshold)
InterfaceHttpPostRequestDecoder
0
to disable it.setDiscardThreshold
in interface InterfaceHttpPostRequestDecoder
public int getDiscardThreshold()
InterfaceHttpPostRequestDecoder
getDiscardThreshold
in interface InterfaceHttpPostRequestDecoder
public List<InterfaceHttpData> getBodyHttpDatas()
InterfaceHttpPostRequestDecoder
getBodyHttpDatas
in interface InterfaceHttpPostRequestDecoder
public List<InterfaceHttpData> getBodyHttpDatas(String name)
InterfaceHttpPostRequestDecoder
getBodyHttpDatas
in interface InterfaceHttpPostRequestDecoder
public InterfaceHttpData getBodyHttpData(String name)
InterfaceHttpPostRequestDecoder
getBodyHttpData
in interface InterfaceHttpPostRequestDecoder
public InterfaceHttpPostRequestDecoder offer(HttpContent content)
InterfaceHttpPostRequestDecoder
offer
in interface InterfaceHttpPostRequestDecoder
content
- the new received chunkpublic boolean hasNext()
InterfaceHttpPostRequestDecoder
hasNext
in interface InterfaceHttpPostRequestDecoder
public InterfaceHttpData next()
InterfaceHttpPostRequestDecoder
ReferenceCounted.release()
after you are done
with processing to make sure to not leak any resourcesnext
in interface InterfaceHttpPostRequestDecoder
public InterfaceHttpData currentPartialHttpData()
InterfaceHttpPostRequestDecoder
currentPartialHttpData
in interface InterfaceHttpPostRequestDecoder
public void destroy()
InterfaceHttpPostRequestDecoder
InterfaceHttpPostRequestDecoder
and release all it resources. After this method
was called it is not possible to operate on it anymore.destroy
in interface InterfaceHttpPostRequestDecoder
public void cleanFiles()
InterfaceHttpPostRequestDecoder
cleanFiles
in interface InterfaceHttpPostRequestDecoder
public void removeHttpDataFromClean(InterfaceHttpData data)
InterfaceHttpPostRequestDecoder
removeHttpDataFromClean
in interface InterfaceHttpPostRequestDecoder
Copyright © 2008–2024 The Netty Project. All rights reserved.