com.google.api.client.http
Class MultipartRelatedContent

java.lang.Object
  extended by com.google.api.client.http.MultipartRelatedContent
All Implemented Interfaces:
HttpContent

public final class MultipartRelatedContent
extends Object
implements HttpContent

Serializes MIME Multipart/Related content as specified by RFC 2387: The MIME Multipart/Related Content-type.

Limitations:

Sample usage:


  static void setMediaWithMetadataContent(HttpRequest request,
      AtomContent atomContent, InputStreamContent imageContent) {
    MultipartRelatedContent content =
        MultipartRelatedContent.forRequest(request);
    content.parts.add(atomContent);
    content.parts.add(imageContent);
  }
 

Since:
1.1
Author:
Yaniv Inbar

Field Summary
 String boundary
          Boundary string to use.
 Collection<HttpContent> parts
          Collection of HTTP content parts.
 
Constructor Summary
MultipartRelatedContent()
           
 
Method Summary
static MultipartRelatedContent forRequest(HttpRequest request)
          Returns a new multi-part content serializer as the content for the given HTTP request.
 String getEncoding()
          Returns the content encoding (for example "gzip") or null for none.
 long getLength()
          Returns the content length or less than zero if not known.
 String getType()
          Returns the content type or null for none.
 boolean retrySupported()
          Returns whether or not retry is supported on this content type.
 void writeTo(OutputStream out)
          Writes the content to the given output stream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

boundary

public String boundary
Boundary string to use. By default, it is "END_OF_PART".


parts

public Collection<HttpContent> parts
Collection of HTTP content parts.

By default, it is an empty list. Note that the content type for each part is required, so HttpContent.getType() must not be null.

Constructor Detail

MultipartRelatedContent

public MultipartRelatedContent()
Method Detail

forRequest

public static MultipartRelatedContent forRequest(HttpRequest request)
Returns a new multi-part content serializer as the content for the given HTTP request.

It also sets the HttpHeaders.mimeVersion of headers to "1.0".

Parameters:
request - HTTP request
Returns:
new multi-part content serializer

writeTo

public void writeTo(OutputStream out)
             throws IOException
Description copied from interface: HttpContent
Writes the content to the given output stream.

Specified by:
writeTo in interface HttpContent
Throws:
IOException

getEncoding

public String getEncoding()
Description copied from interface: HttpContent
Returns the content encoding (for example "gzip") or null for none.

Specified by:
getEncoding in interface HttpContent

getLength

public long getLength()
Description copied from interface: HttpContent
Returns the content length or less than zero if not known.

Specified by:
getLength in interface HttpContent

getType

public String getType()
Description copied from interface: HttpContent
Returns the content type or null for none.

Specified by:
getType in interface HttpContent

retrySupported

public boolean retrySupported()
Description copied from interface: HttpContent
Returns whether or not retry is supported on this content type. This is a backward incompatible change that affects versions prior to 1.4.

Specified by:
retrySupported in interface HttpContent


Copyright © 2010-2011 Google. All Rights Reserved.