Class MockHttpContent (1.43.1)

public class MockHttpContent implements HttpContent

Beta
Mock for HttpContent.

Implementation is not thread-safe.

Inheritance

java.lang.Object > MockHttpContent

Implements

HttpContent

Constructors

MockHttpContent()

public MockHttpContent()

Methods

getContent()

public final byte[] getContent()

Returns the HTTP content.

Returns
TypeDescription
byte[]

getLength()

public long getLength()

Returns the content length or less than zero if not known.

Returns
TypeDescription
long
Exceptions
TypeDescription
IOException

getType()

public String getType()

Returns the content type or null for none.

Returns
TypeDescription
String

retrySupported()

public boolean retrySupported()

Returns whether or not retry is supported on this content type.

Returns
TypeDescription
boolean

setContent(byte[] content)

public MockHttpContent setContent(byte[] content)

Sets the HTTP content.

Default value is an empty byte array.

Parameter
NameDescription
contentbyte[]
Returns
TypeDescription
MockHttpContent

setLength(long length)

public MockHttpContent setLength(long length)

Returns the HTTP content length or -1 for unknown.

Default value is -1.

Parameter
NameDescription
lengthlong
Returns
TypeDescription
MockHttpContent

setType(String type)

public MockHttpContent setType(String type)

Sets the HTTP content type or null for none.

Parameter
NameDescription
typeString
Returns
TypeDescription
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.

Parameter
NameDescription
outOutputStream
Exceptions
TypeDescription
IOException