public class MockClientHttpResponse extends MockHttpInputMessage implements ClientHttpResponse
ClientHttpResponse
.Constructor and Description |
---|
MockClientHttpResponse(byte[] body,
HttpStatus statusCode)
Constructor with response body as a byte array.
|
MockClientHttpResponse(byte[] body,
int statusCode)
Variant of
MockClientHttpResponse(byte[], HttpStatus) with a
custom HTTP status code. |
MockClientHttpResponse(InputStream body,
HttpStatus statusCode)
Constructor with response body as InputStream.
|
MockClientHttpResponse(InputStream body,
int statusCode)
Variant of
MockClientHttpResponse(InputStream, HttpStatus) with a
custom HTTP status code. |
Modifier and Type | Method and Description |
---|---|
void |
close()
Close this response, freeing any resources created.
|
int |
getRawStatusCode()
Get the HTTP status code (potentially non-standard and not
resolvable through the
HttpStatus enum) as an integer. |
HttpStatus |
getStatusCode()
Get the HTTP status code as an
HttpStatus enum value. |
String |
getStatusText()
Get the HTTP status text of the response.
|
getBody, getHeaders
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getBody
getHeaders
public MockClientHttpResponse(byte[] body, HttpStatus statusCode)
public MockClientHttpResponse(byte[] body, int statusCode)
MockClientHttpResponse(byte[], HttpStatus)
with a
custom HTTP status code.public MockClientHttpResponse(InputStream body, HttpStatus statusCode)
public MockClientHttpResponse(InputStream body, int statusCode)
MockClientHttpResponse(InputStream, HttpStatus)
with a
custom HTTP status code.public HttpStatus getStatusCode()
ClientHttpResponse
HttpStatus
enum value.
For status codes not supported by HttpStatus
, use
ClientHttpResponse.getRawStatusCode()
instead.
getStatusCode
in interface ClientHttpResponse
null
)HttpStatus.valueOf(int)
public int getRawStatusCode()
ClientHttpResponse
HttpStatus
enum) as an integer.getRawStatusCode
in interface ClientHttpResponse
ClientHttpResponse.getStatusCode()
,
HttpStatus.resolve(int)
public String getStatusText()
ClientHttpResponse
getStatusText
in interface ClientHttpResponse
public void close()
ClientHttpResponse
close
in interface Closeable
close
in interface AutoCloseable
close
in interface ClientHttpResponse