org.springframework.mock.http.client

## Class MockClientHttpResponse

- java.lang.Object
- - org.springframework.mock.http.MockHttpInputMessage
  - - org.springframework.mock.http.client.MockClientHttpResponse

All Implemented Interfaces:
  Closeable, AutoCloseable, ClientHttpResponse, HttpInputMessage, HttpMessage

    public class MockClientHttpResponse
    extends MockHttpInputMessage
    implements ClientHttpResponse

Mock implementation of `ClientHttpResponse`.

Since:
  3.2
Author:
  Rossen Stoyanchev

### Constructor Summary

Constructors
Constructor and Description
`MockClientHttpResponse(byte[] body, HttpStatus statusCode)` Constructor with response body as a byte array.
`MockClientHttpResponse(InputStream body, HttpStatus statusCode)` Constructor with response body as InputStream.

### Method Summary

Methods
`void` `close()` Closes this response, freeing any resources created.
`int` `getRawStatusCode()` Return the HTTP status code of the response as integer
`HttpStatus` `getStatusCode()` Return the HTTP status code of the response.
`String` `getStatusText()` Return the HTTP status text of the response.

### Methods inherited from class org.springframework.mock.http.MockHttpInputMessage

`getBody, getHeaders`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Methods inherited from interface org.springframework.http.HttpInputMessage

`getBody`

### Methods inherited from interface org.springframework.http.HttpMessage

`getHeaders`

### Constructor Detail

#### MockClientHttpResponse

    public MockClientHttpResponse(byte[] body,
                          HttpStatus statusCode)

Constructor with response body as a byte array.

#### MockClientHttpResponse

    public MockClientHttpResponse(InputStream body,
                          HttpStatus statusCode)

Constructor with response body as InputStream.

### Method Detail

#### getStatusCode

    public HttpStatus getStatusCode()
                             throws IOException

Description copied from interface: `ClientHttpResponse`
Return the HTTP status code of the response.

Specified by:
  `getStatusCode` in interface `ClientHttpResponse`
Returns:
  the HTTP status as an HttpStatus enum value
Throws:
  `IOException` - in case of I/O errors

#### getRawStatusCode

    public int getRawStatusCode()
                         throws IOException

Description copied from interface: `ClientHttpResponse`
Return the HTTP status code of the response as integer

Specified by:
  `getRawStatusCode` in interface `ClientHttpResponse`
Returns:
  the HTTP status as an integer
Throws:
  `IOException` - in case of I/O errors

#### getStatusText

    public String getStatusText()
                         throws IOException

Description copied from interface: `ClientHttpResponse`
Return the HTTP status text of the response.

Specified by:
  `getStatusText` in interface `ClientHttpResponse`
Returns:
  the HTTP status text
Throws:
  `IOException` - in case of I/O errors

#### close

    public void close()

Description copied from interface: `ClientHttpResponse`
Closes this response, freeing any resources created.

Specified by:
  `close` in interface `Closeable`
Specified by:
  `close` in interface `AutoCloseable`
Specified by:
  `close` in interface `ClientHttpResponse`