Class MockHttpContent (1.45.2)

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
Type Description
byte[]

getLength()

public long getLength()

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

Returns
Type Description
long
Exceptions
Type Description
IOException

getType()

public String getType()

Returns the content type or null for none.

Returns
Type Description
String

retrySupported()

public boolean retrySupported()

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

Returns
Type Description
boolean

setContent(byte[] content)

public MockHttpContent setContent(byte[] content)

Sets the HTTP content.

Default value is an empty byte array.

Parameter
Name Description
content byte[]
Returns
Type Description
MockHttpContent

setLength(long length)

public MockHttpContent setLength(long length)

Returns the HTTP content length or -1 for unknown.

Default value is -1.

Parameter
Name Description
length long
Returns
Type Description
MockHttpContent

setType(String type)

public MockHttpContent setType(String type)

Sets the HTTP content type or null for none.

Parameter
Name Description
type String
Returns
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.

Parameter
Name Description
out OutputStream
Exceptions
Type Description
IOException