@Beta public class MockHttpContent extends java.lang.Object implements HttpContent
Constructor and Description |
---|
MockHttpContent() |
Modifier and Type | Method and 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 or
null 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 or
null for none. |
void |
writeTo(java.io.OutputStream out)
Writes the byte content to the given output stream.
|
public long getLength() throws java.io.IOException
HttpContent
getLength
in interface HttpContent
java.io.IOException
public java.lang.String getType()
HttpContent
null
for none.getType
in interface HttpContent
public void writeTo(java.io.OutputStream out) throws java.io.IOException
StreamingContent
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.
writeTo
in interface HttpContent
writeTo
in interface StreamingContent
out
- output streamjava.io.IOException
public boolean retrySupported()
HttpContent
retrySupported
in interface HttpContent
public final byte[] getContent()
public MockHttpContent setContent(byte[] content)
Default value is an empty byte array.
public MockHttpContent setLength(long length)
-1
for unknown.
Default value is -1
.
public MockHttpContent setType(java.lang.String type)
null
for none.Copyright © 2011-2018 Google. All Rights Reserved.