Package com.google.api.client.http
Class EmptyContent
- java.lang.Object
-
- com.google.api.client.http.EmptyContent
-
- All Implemented Interfaces:
HttpContent
,StreamingContent
public class EmptyContent extends java.lang.Object implements HttpContent
Empty HTTP content of length zero just to forceHttpRequest.execute()
to add the headerContent-Length: 0
.Note that there is no
Content-Length
header if the HTTP request content isnull
. However, when making a request like PUT or POST without aContent-Length
header, some servers may respond with a411 Length Required
error. Specifying theContent-Length: 0
header may work around that problem.- Since:
- 1.11
-
-
Constructor Summary
Constructors Constructor Description EmptyContent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description long
getLength()
Returns the content length or less than zero if not known.java.lang.String
getType()
Returns the content type ornull
for none.boolean
retrySupported()
Returns whether or not retry is supported on this content type.void
writeTo(java.io.OutputStream out)
Writes the byte content to the given output stream.
-
-
-
Method Detail
-
getLength
public long getLength() throws java.io.IOException
Description copied from interface:HttpContent
Returns the content length or less than zero if not known.- Specified by:
getLength
in interfaceHttpContent
- Throws:
java.io.IOException
-
getType
public java.lang.String getType()
Description copied from interface:HttpContent
Returns the content type ornull
for none.- Specified by:
getType
in interfaceHttpContent
-
writeTo
public void writeTo(java.io.OutputStream out) throws java.io.IOException
Description copied from interface:StreamingContent
Writes the byte content to the given output stream.Implementations must not close the output stream, and instead should flush the output stream. Some callers may assume that the output stream has not been closed, and will fail to work if it has been closed.
- Specified by:
writeTo
in interfaceHttpContent
- Specified by:
writeTo
in interfaceStreamingContent
- Parameters:
out
- output stream- Throws:
java.io.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 interfaceHttpContent
-
-