public class MockHttpContent implements HttpContent
Implements
HttpContentConstructors
MockHttpContent()
public MockHttpContent()
Methods
getContent()
public final byte[] getContent()
Returns the HTTP content.
Type | Description |
byte[] |
getLength()
public long getLength()
Returns the content length or less than zero if not known.
Type | Description |
long |
Type | Description |
IOException |
getType()
public String getType()
Returns the content type or null
for none.
Type | Description |
String |
retrySupported()
public boolean retrySupported()
Returns whether or not retry is supported on this content type.
Type | Description |
boolean |
setContent(byte[] content)
public MockHttpContent setContent(byte[] content)
Sets the HTTP content.
Default value is an empty byte array.
Name | Description |
content | byte[] |
Type | Description |
MockHttpContent |
setLength(long length)
public MockHttpContent setLength(long length)
Returns the HTTP content length or -1
for unknown.
Default value is -1
.
Name | Description |
length | long |
Type | Description |
MockHttpContent |
setType(String type)
public MockHttpContent setType(String type)
Sets the HTTP content type or null
for none.
Name | Description |
type | String |
Type | Description |
MockHttpContent |
writeTo(OutputStream out)
public void writeTo(OutputStream out)
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.
Name | Description |
out | OutputStream |
Type | Description |
IOException |