HttpMethod
public class MultipartPostMethod extends ExpectContinueMethod
MultipartRequestEntity
in conjunction with PostMethod
instead.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.
Modifier and Type | Field | Description |
---|---|---|
static java.lang.String |
MULTIPART_FORM_CONTENT_TYPE |
Deprecated.
The Content-Type for multipart/form-data.
|
effectiveVersion, statusLine
Constructor | Description |
---|---|
MultipartPostMethod() |
Deprecated.
No-arg constructor.
|
MultipartPostMethod(java.lang.String uri) |
Deprecated.
Constructor specifying a URI.
|
Modifier and Type | Method | Description |
---|---|---|
protected void |
addContentLengthRequestHeader(HttpState state,
HttpConnection conn) |
Deprecated.
Adds a Content-Length request header, as long as no
Content-Length request header already exists.
|
protected void |
addContentTypeRequestHeader(HttpState state,
HttpConnection conn) |
Deprecated.
Adds a Content-Type request header.
|
void |
addParameter(java.lang.String parameterName,
java.io.File parameterFile) |
Deprecated.
Adds a binary file part
|
void |
addParameter(java.lang.String parameterName,
java.lang.String parameterValue) |
Deprecated.
Adds a text field part
|
void |
addParameter(java.lang.String parameterName,
java.lang.String fileName,
java.io.File parameterFile) |
Deprecated.
Adds a binary file part with the given file name
|
void |
addPart(Part part) |
Deprecated.
Adds a part.
|
protected void |
addRequestHeaders(HttpState state,
HttpConnection conn) |
Deprecated.
Populates the request headers map to with additional
headers to be submitted to
the given HttpConnection . |
java.lang.String |
getName() |
Deprecated.
Returns "POST".
|
Part[] |
getParts() |
Deprecated.
Returns all parts.
|
protected long |
getRequestContentLength() |
Deprecated.
Return the length of the request body.
|
protected boolean |
hasRequestContent() |
Deprecated.
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) |
Deprecated.
Writes the request body to the given
connection . |
getUseExpectHeader, setUseExpectHeader
abort, addCookieRequestHeader, addHostRequestHeader, addProxyConnectionHeader, addRequestHeader, addRequestHeader, addResponseFooter, addUserAgentRequestHeader, checkNotUsed, checkUsed, execute, generateRequestLine, getAuthenticationRealm, getContentCharSet, getDoAuthentication, getEffectiveVersion, getFollowRedirects, getHostAuthState, getHostConfiguration, getMethodRetryHandler, getParams, getPath, getProxyAuthenticationRealm, getProxyAuthState, getQueryString, getRecoverableExceptionCount, getRequestCharSet, getRequestHeader, getRequestHeaderGroup, getRequestHeaders, getRequestHeaders, getResponseBody, getResponseBody, getResponseBodyAsStream, getResponseBodyAsString, getResponseBodyAsString, getResponseCharSet, getResponseContentLength, getResponseFooter, getResponseFooters, getResponseHeader, getResponseHeaderGroup, getResponseHeaders, getResponseHeaders, getResponseStream, getResponseTrailerHeaderGroup, getStatusCode, getStatusLine, getStatusText, getURI, hasBeenUsed, isAborted, isConnectionCloseForced, isHttp11, isRequestSent, isStrictMode, processCookieHeaders, processResponseBody, processResponseHeaders, processStatusLine, readResponse, readResponseBody, readResponseHeaders, readStatusLine, releaseConnection, removeRequestHeader, removeRequestHeader, responseBodyConsumed, setConnectionCloseForced, setDoAuthentication, setFollowRedirects, setHostConfiguration, setHttp11, setMethodRetryHandler, setParams, setPath, setQueryString, setQueryString, setRequestHeader, setRequestHeader, setResponseStream, setStrictMode, setURI, shouldCloseConnection, validate, writeRequest, writeRequestHeaders, writeRequestLine
public static final java.lang.String MULTIPART_FORM_CONTENT_TYPE
public MultipartPostMethod()
public MultipartPostMethod(java.lang.String uri)
uri
- either an absolute or relative URIprotected boolean hasRequestContent()
hasRequestContent
in class ExpectContinueMethod
public java.lang.String getName()
getName
in interface HttpMethod
getName
in class HttpMethodBase
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.java.io.FileNotFoundException
- If the file cannot be found.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 filejava.io.FileNotFoundException
- If the file cannot be found.public void addPart(Part part)
part
- The part to add.public Part[] getParts()
protected void addContentLengthRequestHeader(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- current state of http requestsconn
- the connection to use for I/Ojava.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void addContentTypeRequestHeader(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
state
- current state of http requestsconn
- the connection to use for I/Ojava.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected void addRequestHeaders(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
headers
to be submitted to
the given HttpConnection
.
This implementation adds tt>Content-Length and Content-Type headers, when appropriate.
Subclasses may want to override this method to to add additional headers, and may choose to invoke this implementation (via super) to add the "standard" headers.
addRequestHeaders
in class ExpectContinueMethod
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodjava.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.HttpMethodBase.writeRequestHeaders(org.apache.commons.httpclient.HttpState, org.apache.commons.httpclient.HttpConnection)
protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws java.io.IOException, HttpException
connection
.writeRequestBody
in class HttpMethodBase
state
- the state
information associated with this methodconn
- the connection
used to execute
this HTTP methodjava.io.IOException
- if an I/O (transport) error occurs. Some transport exceptions
can be recovered from.HttpException
- if a protocol exception occurs. Usually protocol exceptions
cannot be recovered from.protected long getRequestContentLength() throws java.io.IOException
Return the length of the request body.
Once this method has been invoked, the request parameters cannot be
altered until the method is recycled
.
java.io.IOException
public void recycle()
recycle
in interface HttpMethod
recycle
in class HttpMethodBase
HttpMethodBase.releaseConnection()
Copyright (c) 1999-2005 - Apache Software Foundation