Class MockHttpContent
- java.lang.Object
-
- com.google.api.client.testing.http.MockHttpContent
-
- All Implemented Interfaces:
HttpContent
,StreamingContent
@Beta public class MockHttpContent extends java.lang.Object implements HttpContent
- Since:
- 1.3
-
-
Constructor Summary
Constructors Constructor Description MockHttpContent()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description byte[]
getContent()
Returns the HTTP content.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.MockHttpContent
setContent(byte[] content)
Sets the HTTP content.MockHttpContent
setLength(long length)
Returns the HTTP content length or-1
for unknown.MockHttpContent
setType(java.lang.String type)
Sets the HTTP content type ornull
for none.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 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
-
getContent
public final byte[] getContent()
Returns the HTTP content.- Since:
- 1.5
-
setContent
public MockHttpContent setContent(byte[] content)
Sets the HTTP content.Default value is an empty byte array.
- Since:
- 1.5
-
setLength
public MockHttpContent setLength(long length)
Returns the HTTP content length or-1
for unknown.Default value is
-1
.- Since:
- 1.5
-
setType
public MockHttpContent setType(java.lang.String type)
Sets the HTTP content type ornull
for none.- Since:
- 1.5
-
-