|
||||||||
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 java.lang.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(java.lang.String uri)
Constructor specifying a URI. |
|
MultipartPostMethod(java.lang.String uri,
java.lang.String tempDir)
Constructor specifying a URI and tempDir. |
|
MultipartPostMethod(java.lang.String uri,
java.lang.String tempDir,
java.lang.String tempFile)
Constructor specifying a URI, tempDir and tempFile. |
Method Summary | |
void |
addParameter(java.lang.String parameterName,
java.io.File parameterFile)
Adds a binary file part |
void |
addParameter(java.lang.String parameterName,
java.lang.String parameterValue)
Adds a text field part |
void |
addParameter(java.lang.String parameterName,
java.lang.String fileName,
java.io.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 |
java.lang.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()
Recycles the HTTP method so that it can be used again. |
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 java.lang.String MULTIPART_FORM_CONTENT_TYPE
Constructor Detail |
public MultipartPostMethod()
public MultipartPostMethod(java.lang.String uri)
uri
- either an absolute or relative URIpublic MultipartPostMethod(java.lang.String uri, java.lang.String tempDir)
uri
- either an absolute or relative URItempDir
- directory to store temp files inpublic MultipartPostMethod(java.lang.String uri, java.lang.String tempDir, java.lang.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()
public java.lang.String getName()
public void addParameter(java.lang.String parameterName, java.lang.String parameterValue)
parameterName
- The name of the parameter.parameterValue
- The value of the parameter.public void addParameter(java.lang.String parameterName, java.io.File parameterFile) throws java.io.FileNotFoundException
parameterName
- The name of the parameterparameterFile
- The name of the file.public void addParameter(java.lang.String parameterName, java.lang.String fileName, java.io.File parameterFile) throws java.io.FileNotFoundException
parameterName
- The name of the parameterfileName
- The file nameparameterFile
- The filepublic void addPart(Part part)
part
- The part to add.public Part[] getParts()
protected void addRequestHeaders(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodprotected boolean writeRequestBody(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.state
- the state
information associated with this methodconn
- the connection
used to execute
this 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
.
public void recycle()
HttpMethodBase.releaseConnection()
|
||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||
SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |