Class MultipartPostMethod

  • All Implemented Interfaces:
    HttpMethod

    public class MultipartPostMethod
    extends ExpectContinueMethod
    Deprecated.
    Use MultipartRequestEntity in conjunction with PostMethod instead.
    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 Detail

      • MULTIPART_FORM_CONTENT_TYPE

        public static final java.lang.String MULTIPART_FORM_CONTENT_TYPE
        Deprecated.
        The Content-Type for multipart/form-data.
        See Also:
        Constant Field Values
    • Constructor Detail

      • MultipartPostMethod

        public MultipartPostMethod()
        Deprecated.
        No-arg constructor.
      • MultipartPostMethod

        public MultipartPostMethod​(java.lang.String uri)
        Deprecated.
        Constructor specifying a URI.
        Parameters:
        uri - either an absolute or relative URI
    • Method Detail

      • addParameter

        public void addParameter​(java.lang.String parameterName,
                                 java.lang.String parameterValue)
        Deprecated.
        Adds a text field part
        Parameters:
        parameterName - The name of the parameter.
        parameterValue - The value of the parameter.
      • addParameter

        public void addParameter​(java.lang.String parameterName,
                                 java.io.File parameterFile)
                          throws java.io.FileNotFoundException
        Deprecated.
        Adds a binary file part
        Parameters:
        parameterName - The name of the parameter
        parameterFile - The name of the file.
        Throws:
        java.io.FileNotFoundException - If the file cannot be found.
      • addParameter

        public void addParameter​(java.lang.String parameterName,
                                 java.lang.String fileName,
                                 java.io.File parameterFile)
                          throws java.io.FileNotFoundException
        Deprecated.
        Adds a binary file part with the given file name
        Parameters:
        parameterName - The name of the parameter
        fileName - The file name
        parameterFile - The file
        Throws:
        java.io.FileNotFoundException - If the file cannot be found.
      • addPart

        public void addPart​(Part part)
        Deprecated.
        Adds a part.
        Parameters:
        part - The part to add.
      • getParts

        public Part[] getParts()
        Deprecated.
        Returns all parts.
        Returns:
        an array of containing all parts
      • addContentLengthRequestHeader

        protected void addContentLengthRequestHeader​(HttpState state,
                                                     HttpConnection conn)
                                              throws java.io.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 requests
        conn - the connection to use for I/O
        Throws:
        java.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.
        Since:
        3.0
      • addContentTypeRequestHeader

        protected void addContentTypeRequestHeader​(HttpState state,
                                                   HttpConnection conn)
                                            throws java.io.IOException,
                                                   HttpException
        Deprecated.
        Adds a Content-Type request header.
        Parameters:
        state - current state of http requests
        conn - the connection to use for I/O
        Throws:
        java.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.
        Since:
        3.0
      • writeRequestBody

        protected boolean writeRequestBody​(HttpState state,
                                           HttpConnection conn)
                                    throws java.io.IOException,
                                           HttpException
        Deprecated.
        Writes the request body to the given connection.
        Overrides:
        writeRequestBody in class HttpMethodBase
        Parameters:
        state - the state information associated with this method
        conn - the connection used to execute this HTTP method
        Returns:
        true
        Throws:
        java.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.
      • getRequestContentLength

        protected long getRequestContentLength()
                                        throws java.io.IOException
        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:
        java.io.IOException
      • recycle

        public void recycle()
        Deprecated.
        no longer supported and will be removed in the future version of HttpClient
        Recycles 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:
        recycle in interface HttpMethod
        Overrides:
        recycle in class HttpMethodBase
        See Also:
        HttpMethodBase.releaseConnection()