public class

HttpMultipart

extends Object
java.lang.Object
   ↳ org.apache.http.entity.mime.HttpMultipart

Class Overview

HttpMultipart represents a collection of MIME multipart encoded content bodies. This class is capable of operating either in the strict (RFC 822, RFC 2045, RFC 2046 compliant) or the browser compatible modes.

Summary

Public Constructors
HttpMultipart(String subType, Charset charset, String boundary, HttpMultipartMode mode)
Creates an instance with the specified settings.
HttpMultipart(String subType, Charset charset, String boundary)
Creates an instance with the specified settings.
HttpMultipart(String subType, String boundary)
Public Methods
void addBodyPart(FormBodyPart part)
List<FormBodyPart> getBodyParts()
String getBoundary()
Charset getCharset()
HttpMultipartMode getMode()
String getSubType()
long getTotalLength()
Determines the total length of the multipart content (content length of individual parts plus that of extra elements required to delimit the parts from one another).
void writeTo(OutputStream out)
Writes out the content in the multipart/form encoding.
[Expand]
Inherited Methods
From class java.lang.Object

Public Constructors

public HttpMultipart (String subType, Charset charset, String boundary, HttpMultipartMode mode)

Creates an instance with the specified settings.

Parameters
subType mime subtype - must not be null
charset the character set to use. May be null, in which case DEFAULT_CHARSET - i.e. US-ASCII - is used.
boundary to use - must not be null
mode the mode to use
Throws
IllegalArgumentException if charset is null or boundary is null

public HttpMultipart (String subType, Charset charset, String boundary)

Creates an instance with the specified settings. Mode is set to STRICT

Parameters
subType mime subtype - must not be null
charset the character set to use. May be null, in which case DEFAULT_CHARSET - i.e. US-ASCII - is used.
boundary to use - must not be null
Throws
IllegalArgumentException if charset is null or boundary is null

public HttpMultipart (String subType, String boundary)

Public Methods

public void addBodyPart (FormBodyPart part)

public List<FormBodyPart> getBodyParts ()

public String getBoundary ()

public Charset getCharset ()

public HttpMultipartMode getMode ()

public String getSubType ()

public long getTotalLength ()

Determines the total length of the multipart content (content length of individual parts plus that of extra elements required to delimit the parts from one another). If any of the @{link BodyPart}s contained in this object is of a streaming entity of unknown length the total length is also unknown.

This method buffers only a small amount of data in order to determine the total length of the entire entity. The content of individual parts is not buffered.

Returns
  • total length of the multipart entity if known, -1 otherwise.

public void writeTo (OutputStream out)

Writes out the content in the multipart/form encoding. This method produces slightly different formatting depending on its compatibility mode.

Throws
IOException
See Also