Class MultipartPostMethod
java.lang.Object
org.apache.commons.httpclient.HttpMethodBase
org.apache.commons.httpclient.methods.ExpectContinueMethod
org.apache.commons.httpclient.methods.MultipartPostMethod
- All Implemented Interfaces:
HttpMethod
Deprecated.
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.
- Since:
- 2.0
- Author:
- Matthew Albright, Jeff Dever, Adrian Sutton, Mark Diggory, Mike Bowler, Oleg Kalnichevski
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringDeprecated.The Content-Type for multipart/form-data.Fields inherited from class HttpMethodBase
effectiveVersion, statusLine -
Constructor Summary
ConstructorsConstructorDescriptionDeprecated.No-arg constructor.Deprecated.Constructor specifying a URI. -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddContentLengthRequestHeader(HttpState state, HttpConnection conn) Deprecated.Adds a Content-Length request header, as long as no Content-Length request header already exists.protected voidaddContentTypeRequestHeader(HttpState state, HttpConnection conn) Deprecated.Adds a Content-Type request header.voidaddParameter(String parameterName, File parameterFile) Deprecated.Adds a binary file partvoidaddParameter(String parameterName, String parameterValue) Deprecated.Adds a text field partvoidaddParameter(String parameterName, String fileName, File parameterFile) Deprecated.Adds a binary file part with the given file namevoidDeprecated.Adds a part.protected voidaddRequestHeaders(HttpState state, HttpConnection conn) Deprecated.Populates the request headers map to with additionalheadersto be submitted to the givenHttpConnection.getName()Deprecated.Returns "POST".Part[]getParts()Deprecated.Returns all parts.protected longDeprecated.Return the length of the request body.protected booleanDeprecated.Returns truevoidrecycle()Deprecated.no longer supported and will be removed in the future version of HttpClientprotected booleanwriteRequestBody(HttpState state, HttpConnection conn) Deprecated.Writes the request body to the givenconnection.Methods inherited from class ExpectContinueMethod
getUseExpectHeader, setUseExpectHeaderMethods inherited from class HttpMethodBase
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
-
Field Details
-
MULTIPART_FORM_CONTENT_TYPE
Deprecated.The Content-Type for multipart/form-data.- See Also:
-
-
Constructor Details
-
MultipartPostMethod
public MultipartPostMethod()Deprecated.No-arg constructor. -
MultipartPostMethod
Deprecated.Constructor specifying a URI.- Parameters:
uri- either an absolute or relative URI
-
-
Method Details
-
hasRequestContent
protected boolean hasRequestContent()Deprecated.Returns true- Specified by:
hasRequestContentin classExpectContinueMethod- Returns:
- true
- Since:
- 2.0beta1
-
getName
Deprecated.Returns "POST".- Specified by:
getNamein interfaceHttpMethod- Specified by:
getNamein classHttpMethodBase- Returns:
- "POST"
-
addParameter
-
addParameter
Deprecated.Adds a binary file part- Parameters:
parameterName- The name of the parameterparameterFile- The name of the file.- Throws:
FileNotFoundException- If the file cannot be found.
-
addParameter
public void addParameter(String parameterName, String fileName, File parameterFile) throws FileNotFoundException Deprecated.Adds a binary file part with the given file name- Parameters:
parameterName- The name of the parameterfileName- The file nameparameterFile- The file- Throws:
FileNotFoundException- If the file cannot be found.
-
addPart
-
getParts
-
addContentLengthRequestHeader
protected void addContentLengthRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException Deprecated.Adds a Content-Length request header, as long as no Content-Length request header already exists.- Parameters:
state- current state of http requestsconn- the connection to use for I/O- Throws:
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.- Since:
- 3.0
-
addContentTypeRequestHeader
protected void addContentTypeRequestHeader(HttpState state, HttpConnection conn) throws IOException, HttpException Deprecated.Adds a Content-Type request header.- Parameters:
state- current state of http requestsconn- the connection to use for I/O- Throws:
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.- Since:
- 3.0
-
addRequestHeaders
protected void addRequestHeaders(HttpState state, HttpConnection conn) throws IOException, HttpException Deprecated.Populates the request headers map to with additionalheadersto be submitted to the givenHttpConnection.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.
- Overrides:
addRequestHeadersin classExpectContinueMethod- Parameters:
state- thestateinformation associated with this methodconn- theconnectionused to execute this HTTP method- Throws:
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.- See Also:
-
writeRequestBody
protected boolean writeRequestBody(HttpState state, HttpConnection conn) throws IOException, HttpException Deprecated.Writes the request body to the givenconnection.- Overrides:
writeRequestBodyin classHttpMethodBase- Parameters:
state- thestateinformation associated with this methodconn- theconnectionused to execute this HTTP method- Returns:
- true
- Throws:
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.
-
getRequestContentLength
Deprecated.Return the length of the request body.
Once this method has been invoked, the request parameters cannot be altered until the method is
recycled.- Returns:
- The request content length.
- Throws:
IOException
-
recycle
public void recycle()Deprecated.no longer supported and will be removed in the future version of HttpClientRecycles the HTTP method so that it can be used again. Note that all of the instance variables will be reset once this method has been called. This method will also release the connection being used by this HTTP method.- Specified by:
recyclein interfaceHttpMethod- Overrides:
recyclein classHttpMethodBase- See Also:
-
MultipartRequestEntityin conjunction withPostMethodinstead.