public class DefaultResponseCreator extends java.lang.Object implements ResponseCreator
ResponseCreator
with builder-style methods for adding response details.Modifier and Type | Field and Description |
---|---|
private byte[] |
content |
private Resource |
contentResource |
private HttpHeaders |
headers |
private HttpStatus |
statusCode |
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(java.lang.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(java.net.URI location)
Set the
Location header. |
private byte[] content
private Resource contentResource
private final HttpHeaders headers
private HttpStatus statusCode
protected DefaultResponseCreator(HttpStatus statusCode)
MockRestResponseCreators
.public ClientHttpResponse createResponse(ClientHttpRequest request) throws java.io.IOException
ResponseCreator
createResponse
in interface ResponseCreator
request
- the requestjava.io.IOException
public DefaultResponseCreator body(java.lang.String content)
public DefaultResponseCreator body(byte[] content)
public DefaultResponseCreator body(Resource resource)
Resource
.public DefaultResponseCreator contentType(MediaType mediaType)
Content-Type
header.public DefaultResponseCreator location(java.net.URI location)
Location
header.public DefaultResponseCreator headers(HttpHeaders headers)