com.google.api.client.http
Class EmptyContent

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

public class EmptyContent
extends Object
implements HttpContent

Empty HTTP content of length zero just to force HttpRequest.execute() to add the header Content-Length: 0.

Note that there is no Content-Length header if the HTTP request content is null . However, when making a request like PUT or POST without a Content-Length header, some servers may respond with a 411 Length Required error. Specifying the Content-Length: 0 header may work around that problem.

Since:
1.11
Author:
Yaniv Inbar

Constructor Summary
EmptyContent()
           
 
Method Summary
 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
 

Constructor Detail

EmptyContent

public EmptyContent()
Method Detail

getLength

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

Specified by:
getLength 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

getType

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

Specified by:
getType in interface HttpContent

writeTo

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

The recommendation for implementations is that they should not close the output stream. Callers should not assume whether or not the output stream has been closed. Implementations that do not close the output stream should flush it at the end of the method.

Specified by:
writeTo in interface HttpContent
Throws:
IOException

retrySupported

public boolean retrySupported()
Description copied from interface: HttpContent
Returns whether or not retry is supported on this content type.

Specified by:
retrySupported in interface HttpContent


Copyright © 2011-2012 Google. All Rights Reserved.