|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.apache.commons.httpclient.HttpMethodBase | +--org.apache.commons.httpclient.methods.GetMethod | +--org.apache.commons.httpclient.methods.ExpectContinueMethod | +--org.apache.commons.httpclient.methods.MultipartPostMethod
Implements the HTTP multipart POST method.
The HTTP multipart POST method is defined in section 3.3 of RFC1867:
The media-type multipart/form-data follows the rules of all multipart MIME data streams as outlined in RFC 1521. The multipart/form-data contains a series of parts. Each part is expected to contain a content-disposition header where the value is "form-data" and a name attribute specifies the field name within the form, e.g., 'content-disposition: form-data; name="xxxxx"', where xxxxx is the field name corresponding to that field. Field names originally in non-ASCII character sets may be encoded using the method outlined in RFC 1522.
Field Summary | |
static String |
MULTIPART_FORM_CONTENT_TYPE
The Content-Type for multipart/form-data. |
Fields inherited from class org.apache.commons.httpclient.HttpMethodBase |
USER_AGENT |
Constructor Summary | |
MultipartPostMethod()
No-arg constructor. |
|
MultipartPostMethod(String uri)
Constructor specifying a URI. |
|
MultipartPostMethod(String uri,
String tempDir)
Constructor specifying a URI and tempDir. |
|
MultipartPostMethod(String uri,
String tempDir,
String tempFile)
Constructor specifying a URI, tempDir and tempFile. |
Method Summary | |
void |
addParameter(String parameterName,
File parameterFile)
Adds a binary file part |
void |
addParameter(String parameterName,
String parameterValue)
Adds a text field part |
void |
addParameter(String parameterName,
String fileName,
File parameterFile)
Adds a binary file part with the given file name |
void |
addPart(Part part)
Adds a part. |
protected void |
addRequestHeaders(HttpState state,
HttpConnection conn)
Adds Content Type: multipart/form-data header in addition to the "standard" set of headers |
String |
getName()
Returns "POST". |
Part[] |
getParts()
Returns all parts. |
protected int |
getRequestContentLength()
Return the length of the request body. |
protected boolean |
hasRequestContent()
Returns true |
void |
recycle()
Deprecated. no longer supported and will be removed in the future version of HttpClient |
protected boolean |
writeRequestBody(HttpState state,
HttpConnection conn)
Writes the request body to the given connection . |
Methods inherited from class org.apache.commons.httpclient.methods.ExpectContinueMethod |
getUseExpectHeader, setUseExpectHeader |
Methods inherited from class org.apache.commons.httpclient.methods.GetMethod |
getFileData, getTempDir, getTempFile, getUseDisk, readResponseBody, setFileData, setTempDir, setTempFile, setUseDisk |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String MULTIPART_FORM_CONTENT_TYPE
Constructor Detail |
public MultipartPostMethod()
public MultipartPostMethod(String uri)
uri
- either an absolute or relative URIpublic MultipartPostMethod(String uri, String tempDir)
uri
- either an absolute or relative URItempDir
- directory to store temp files inpublic MultipartPostMethod(String uri, String tempDir, String tempFile)
uri
- either an absolute or relative URItempDir
- directory to store temp files intempFile
- file to store temporary data inMethod Detail |
protected boolean hasRequestContent()
hasRequestContent
in class ExpectContinueMethod
public String getName()
getName
in class GetMethod
public void addParameter(String parameterName, String parameterValue)
parameterName
- The name of the parameter.parameterValue
- The value of the parameter.public void addParameter(String parameterName, File parameterFile) throws FileNotFoundException
parameterName
- The name of the parameterparameterFile
- The name of the file.FileNotFoundException
- If the file cannot be found.public void addParameter(String parameterName, String fileName, File parameterFile) throws FileNotFoundException
parameterName
- The name of the parameterfileName
- The file nameparameterFile
- The fileFileNotFoundException
- If the file cannot be found.public void addPart(Part part)
part
- The part to add.public Part[] getParts()
protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException
addRequestHeaders
in class ExpectContinueMethod
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodIOException
- if an I/O (transport) error occursHttpException
- if a protocol exception occurs.HttpRecoverableException
- if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodprotected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException
connection
.writeRequestBody
in class HttpMethodBase
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodIOException
- if an I/O (transport) error occursHttpException
- if a protocol exception occurs.HttpRecoverableException
- if a recoverable transport error occurs.
Usually this kind of exceptions can be recovered from by
retrying the HTTP methodprotected int getRequestContentLength()
Return the length of the request body.
Once this method has been invoked, the request parameters cannot be
altered until the method is recycled
.
getRequestContentLength
in class HttpMethodBase
public void recycle()
recycle
in class GetMethod
HttpMethodBase.releaseConnection()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |