public class DefaultResponseCreator extends Object implements ResponseCreator
ResponseCreator
with builder-style methods for adding response details.Modifier | Constructor and Description |
---|---|
protected |
DefaultResponseCreator(HttpStatus statusCode)
Protected constructor.
|
Modifier and Type | Method and Description |
---|---|
DefaultResponseCreator |
body(byte[] content)
Set the body as a byte array.
|
DefaultResponseCreator |
body(Resource resource)
Set the body as a
Resource . |
DefaultResponseCreator |
body(String content)
Set the body as a UTF-8 String.
|
DefaultResponseCreator |
contentType(MediaType mediaType)
Set the
Content-Type header. |
ClientHttpResponse |
createResponse(ClientHttpRequest request)
Create a response for the given request.
|
DefaultResponseCreator |
headers(HttpHeaders headers)
Copy all given headers.
|
DefaultResponseCreator |
location(URI location)
Set the
Location header. |
protected DefaultResponseCreator(HttpStatus statusCode)
MockRestResponseCreators
.public DefaultResponseCreator body(String content)
public DefaultResponseCreator body(byte[] content)
public DefaultResponseCreator body(Resource resource)
Resource
.public DefaultResponseCreator contentType(MediaType mediaType)
Content-Type
header.public DefaultResponseCreator location(URI location)
Location
header.public DefaultResponseCreator headers(HttpHeaders headers)
public ClientHttpResponse createResponse(@Nullable ClientHttpRequest request) throws IOException
ResponseCreator
createResponse
in interface ResponseCreator
request
- the requestIOException