Package org.apache.http.entity.mime
Class AbstractMultipartForm
- java.lang.Object
-
- org.apache.http.entity.mime.AbstractMultipartForm
-
- Direct Known Subclasses:
HttpBrowserCompatibleMultipart
,HttpMultipart
,HttpRFC6532Multipart
,HttpStrictMultipart
abstract class AbstractMultipartForm extends java.lang.Object
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.- Since:
- 4.3
-
-
Field Summary
Fields Modifier and Type Field Description (package private) java.lang.String
boundary
(package private) java.nio.charset.Charset
charset
private static org.apache.http.util.ByteArrayBuffer
CR_LF
private static org.apache.http.util.ByteArrayBuffer
FIELD_SEP
private static org.apache.http.util.ByteArrayBuffer
TWO_DASHES
-
Constructor Summary
Constructors Constructor Description AbstractMultipartForm(java.lang.String boundary)
AbstractMultipartForm(java.nio.charset.Charset charset, java.lang.String boundary)
Creates an instance with the specified settings.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description (package private) void
doWriteTo(java.io.OutputStream out, boolean writeContent)
private static org.apache.http.util.ByteArrayBuffer
encode(java.nio.charset.Charset charset, java.lang.String string)
protected abstract void
formatMultipartHeader(FormBodyPart part, java.io.OutputStream out)
Write the multipart header fields; depends on the style.abstract java.util.List<FormBodyPart>
getBodyParts()
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).private static void
writeBytes(java.lang.String s, java.io.OutputStream out)
private static void
writeBytes(java.lang.String s, java.nio.charset.Charset charset, java.io.OutputStream out)
private static void
writeBytes(org.apache.http.util.ByteArrayBuffer b, java.io.OutputStream out)
protected static void
writeField(MinimalField field, java.io.OutputStream out)
protected static void
writeField(MinimalField field, java.nio.charset.Charset charset, java.io.OutputStream out)
void
writeTo(java.io.OutputStream out)
Writes out the content in the multipart/form encoding.
-
-
-
Field Detail
-
FIELD_SEP
private static final org.apache.http.util.ByteArrayBuffer FIELD_SEP
-
CR_LF
private static final org.apache.http.util.ByteArrayBuffer CR_LF
-
TWO_DASHES
private static final org.apache.http.util.ByteArrayBuffer TWO_DASHES
-
charset
final java.nio.charset.Charset charset
-
boundary
final java.lang.String boundary
-
-
Constructor Detail
-
AbstractMultipartForm
public AbstractMultipartForm(java.nio.charset.Charset charset, java.lang.String boundary)
Creates an instance with the specified settings.- Parameters:
charset
- the character set to use. May benull
, in which caseMIME.DEFAULT_CHARSET
- i.e. US-ASCII - is used.boundary
- to use - must not benull
- Throws:
java.lang.IllegalArgumentException
- if charset is null or boundary is null
-
AbstractMultipartForm
public AbstractMultipartForm(java.lang.String boundary)
-
-
Method Detail
-
encode
private static org.apache.http.util.ByteArrayBuffer encode(java.nio.charset.Charset charset, java.lang.String string)
-
writeBytes
private static void writeBytes(org.apache.http.util.ByteArrayBuffer b, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBytes
private static void writeBytes(java.lang.String s, java.nio.charset.Charset charset, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
writeBytes
private static void writeBytes(java.lang.String s, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
writeField
protected static void writeField(MinimalField field, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
writeField
protected static void writeField(MinimalField field, java.nio.charset.Charset charset, java.io.OutputStream out) throws java.io.IOException
- Throws:
java.io.IOException
-
getBodyParts
public abstract java.util.List<FormBodyPart> getBodyParts()
-
doWriteTo
void doWriteTo(java.io.OutputStream out, boolean writeContent) throws java.io.IOException
- Throws:
java.io.IOException
-
formatMultipartHeader
protected abstract void formatMultipartHeader(FormBodyPart part, java.io.OutputStream out) throws java.io.IOException
Write the multipart header fields; depends on the style.- Throws:
java.io.IOException
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException
Writes out the content in the multipart/form encoding. This method produces slightly different formatting depending on its compatibility mode.- Throws:
java.io.IOException
-
getTotalLength
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.
-
-