|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.google.api.client.http.AbstractHttpContent
com.google.api.client.http.MultipartRelatedContent
public final class MultipartRelatedContent
Serializes MIME Multipart/Related content as specified by RFC 2387: The MIME Multipart/Related Content-type.
Limitations:
"boundary"
HttpContent.getType()
must not be
null
Use forRequest(HttpRequest)
to construct. For example:
static void setMediaWithMetadataContent(
HttpRequest request, AtomContent atomContent, InputStreamContent imageContent) {
MultipartRelatedContent.forRequest(request, atomContent, imageContent);
}
Implementation is not thread-safe.
Constructor Summary | |
---|---|
MultipartRelatedContent(HttpContent firstPart,
HttpContent... otherParts)
|
Method Summary | |
---|---|
long |
computeLength()
Computes and returns the content length or less than zero if not known. |
void |
forRequest(HttpRequest request)
Sets this multi-part content as the content for the given HTTP request, and set the MIME version header to "1.0" . |
String |
getBoundary()
Returns the boundary string to use. |
Collection<HttpContent> |
getParts()
Returns the HTTP content parts. |
String |
getType()
Returns the content type or null for none. |
boolean |
retrySupported()
Default implementation returns true , but subclasses may override. |
MultipartRelatedContent |
setBoundary(String boundary)
Sets the boundary string to use. |
void |
writeTo(OutputStream out)
Writes the content to the given output stream. |
Methods inherited from class com.google.api.client.http.AbstractHttpContent |
---|
getEncoding, getLength |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public MultipartRelatedContent(HttpContent firstPart, HttpContent... otherParts)
firstPart
- first HTTP content partotherParts
- other HTTP content partsMethod Detail |
---|
public void forRequest(HttpRequest request)
MIME version header
to "1.0"
.
request
- HTTP requestpublic void writeTo(OutputStream out) throws IOException
HttpContent
IOException
public long computeLength() throws IOException
AbstractHttpContent
Subclasses may override, but by default this computes the length by calling
HttpContent.writeTo(OutputStream)
with an output stream that does not process the bytes written,
but only retains the count of bytes. If AbstractHttpContent.retrySupported()
is false
, it will
instead return -1
.
computeLength
in class AbstractHttpContent
IOException
public String getType()
HttpContent
null
for none.
public boolean retrySupported()
AbstractHttpContent
true
, but subclasses may override.
retrySupported
in interface HttpContent
retrySupported
in class AbstractHttpContent
public String getBoundary()
public MultipartRelatedContent setBoundary(String boundary)
Defaults to "END_OF_PART"
.
public Collection<HttpContent> getParts()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |