public class EmptyContent extends Object implements HttpContent
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.
| Constructor and Description |
|---|
EmptyContent() |
| Modifier and Type | Method and Description |
|---|---|
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.
|
public long getLength()
throws IOException
HttpContentgetLength in interface HttpContentIOExceptionpublic String getEncoding()
HttpContent"gzip") or null for none.getEncoding in interface HttpContentpublic String getType()
HttpContentnull for none.getType in interface HttpContentpublic void writeTo(OutputStream out) throws IOException
HttpContentThe 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.
writeTo in interface HttpContentIOExceptionpublic boolean retrySupported()
HttpContentretrySupported in interface HttpContentCopyright © 2011-2012 Google. All Rights Reserved.