public class HttpPostRequestEncoder extends java.lang.Object implements ChunkedInput
限定符和类型 | 类和说明 |
---|---|
static class |
HttpPostRequestEncoder.EncoderMode
Different modes to use to encode form data.
|
static class |
HttpPostRequestEncoder.ErrorDataEncoderException
Exception when an error occurs while encoding
|
构造器和说明 |
---|
HttpPostRequestEncoder(HttpDataFactory factory,
HttpRequest request,
boolean multipart) |
HttpPostRequestEncoder(HttpDataFactory factory,
HttpRequest request,
boolean multipart,
java.nio.charset.Charset charset) |
HttpPostRequestEncoder(HttpDataFactory factory,
HttpRequest request,
boolean multipart,
java.nio.charset.Charset charset,
HttpPostRequestEncoder.EncoderMode encoderMode) |
HttpPostRequestEncoder(HttpRequest request,
boolean multipart) |
限定符和类型 | 方法和说明 |
---|---|
void |
addBodyAttribute(java.lang.String name,
java.lang.String value)
Add a simple attribute in the body as Name=Value
|
void |
addBodyFileUpload(java.lang.String name,
java.io.File file,
java.lang.String contentType,
boolean isText)
Add a file as a FileUpload
|
void |
addBodyFileUploads(java.lang.String name,
java.io.File[] file,
java.lang.String[] contentType,
boolean[] isText)
Add a series of Files associated with one File parameter
|
void |
addBodyHttpData(InterfaceHttpData data)
Add the InterfaceHttpData to the Body list
|
void |
cleanFiles()
Clean all HttpDatas (on Disk) for the current request.
|
void |
close()
Releases the resources associated with the stream.
|
HttpRequest |
finalizeRequest()
Finalize the request by preparing the Header in the request and
returns the request ready to be sent.
|
java.util.List<InterfaceHttpData> |
getBodyListAttributes()
This method returns a List of all InterfaceHttpData from body part.
|
boolean |
hasNextChunk()
Returns
true if and only if there is any data left in the
stream. |
boolean |
isChunked() |
boolean |
isEndOfInput()
Return
true if and only if there is no data left in the stream
and the stream has reached at its end. |
boolean |
isMultipart()
True if this request is a Multipart request
|
HttpChunk |
nextChunk()
Returns the next available HttpChunk.
|
void |
setBodyHttpDatas(java.util.List<InterfaceHttpData> datas)
Set the Body HttpDatas list
|
public HttpPostRequestEncoder(HttpRequest request, boolean multipart) throws HttpPostRequestEncoder.ErrorDataEncoderException
request
- the request to encodemultipart
- True if the FORM is a ENCTYPE="multipart/form-data"java.lang.NullPointerException
- for requestHttpPostRequestEncoder.ErrorDataEncoderException
- if the request is not a POSTpublic HttpPostRequestEncoder(HttpDataFactory factory, HttpRequest request, boolean multipart) throws HttpPostRequestEncoder.ErrorDataEncoderException
factory
- the factory used to create InterfaceHttpDatarequest
- the request to encodemultipart
- True if the FORM is a ENCTYPE="multipart/form-data"java.lang.NullPointerException
- for request and factoryHttpPostRequestEncoder.ErrorDataEncoderException
- if the request is not a POSTpublic HttpPostRequestEncoder(HttpDataFactory factory, HttpRequest request, boolean multipart, java.nio.charset.Charset charset) throws HttpPostRequestEncoder.ErrorDataEncoderException
factory
- the factory used to create InterfaceHttpDatarequest
- the request to encodemultipart
- True if the FORM is a ENCTYPE="multipart/form-data"charset
- the charset to use as defaultjava.lang.NullPointerException
- for request or charset or factoryHttpPostRequestEncoder.ErrorDataEncoderException
- if the request is not a POSTpublic HttpPostRequestEncoder(HttpDataFactory factory, HttpRequest request, boolean multipart, java.nio.charset.Charset charset, HttpPostRequestEncoder.EncoderMode encoderMode) throws HttpPostRequestEncoder.ErrorDataEncoderException
factory
- the factory used to create InterfaceHttpDatarequest
- the request to encodemultipart
- True if the FORM is a ENCTYPE="multipart/form-data"charset
- the charset to use as default
+ @param encoderMode the mode for the encoder to use. See HttpPostRequestEncoder.EncoderMode
for the details.java.lang.NullPointerException
- for request or charset or factoryHttpPostRequestEncoder.ErrorDataEncoderException
- if the request is not a POSTpublic void cleanFiles()
public boolean isMultipart()
public java.util.List<InterfaceHttpData> getBodyListAttributes()
public void setBodyHttpDatas(java.util.List<InterfaceHttpData> datas) throws HttpPostRequestEncoder.ErrorDataEncoderException
java.lang.NullPointerException
- for datasHttpPostRequestEncoder.ErrorDataEncoderException
- if the encoding is in error or if the finalize were already donepublic void addBodyAttribute(java.lang.String name, java.lang.String value) throws HttpPostRequestEncoder.ErrorDataEncoderException
name
- name of the parametervalue
- the value of the parameterjava.lang.NullPointerException
- for nameHttpPostRequestEncoder.ErrorDataEncoderException
- if the encoding is in error or if the finalize were already donepublic void addBodyFileUpload(java.lang.String name, java.io.File file, java.lang.String contentType, boolean isText) throws HttpPostRequestEncoder.ErrorDataEncoderException
name
- the name of the parameterfile
- the file to be uploaded (if not Multipart mode, only the filename will be included)contentType
- the associated contentType for the FileisText
- True if this file should be transmitted in Text format (else binary)java.lang.NullPointerException
- for name and fileHttpPostRequestEncoder.ErrorDataEncoderException
- if the encoding is in error or if the finalize were already donepublic void addBodyFileUploads(java.lang.String name, java.io.File[] file, java.lang.String[] contentType, boolean[] isText) throws HttpPostRequestEncoder.ErrorDataEncoderException
name
- the name of the parameterfile
- the array of filescontentType
- the array of content Types associated with each fileisText
- the array of isText attribute (False meaning binary mode) for each filejava.lang.NullPointerException
- also throws if array have different sizesHttpPostRequestEncoder.ErrorDataEncoderException
- if the encoding is in error or if the finalize were already donepublic void addBodyHttpData(InterfaceHttpData data) throws HttpPostRequestEncoder.ErrorDataEncoderException
java.lang.NullPointerException
- for dataHttpPostRequestEncoder.ErrorDataEncoderException
- if the encoding is in error or if the finalize were already donepublic HttpRequest finalizeRequest() throws HttpPostRequestEncoder.ErrorDataEncoderException
HttpPostRequestEncoder.ErrorDataEncoderException
- if the encoding is in error or if the finalize were already donepublic boolean isChunked()
public void close() throws java.lang.Exception
ChunkedInput
close
在接口中 ChunkedInput
java.lang.Exception
public HttpChunk nextChunk() throws HttpPostRequestEncoder.ErrorDataEncoderException
nextChunk
在接口中 ChunkedInput
HttpPostRequestEncoder.ErrorDataEncoderException
- if the encoding is in errorpublic boolean isEndOfInput() throws java.lang.Exception
ChunkedInput
true
if and only if there is no data left in the stream
and the stream has reached at its end.isEndOfInput
在接口中 ChunkedInput
java.lang.Exception
public boolean hasNextChunk() throws java.lang.Exception
ChunkedInput
true
if and only if there is any data left in the
stream. Please note that false
does not necessarily mean that
the stream has reached at its end. In a slow stream, the next chunk
might be unavailable just momentarily.hasNextChunk
在接口中 ChunkedInput
java.lang.Exception