类 DefaultResponseCreator
- java.lang.Object
- org.springframework.test.web.client.response.DefaultResponseCreator
- 所有已实现的接口:
ResponseCreator
public class DefaultResponseCreator extends Object implements ResponseCreator
AResponseCreator
with builder-style methods for adding response details.- 从以下版本开始:
- 3.2
- 作者:
- Rossen Stoyanchev
构造器概要
构造器 限定符 构造器 说明 protected
DefaultResponseCreator(HttpStatus statusCode)
Protected constructor.
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 DefaultResponseCreator
body(byte[] content)
Set the body as a byte array.DefaultResponseCreator
body(String content)
Set the body as a UTF-8 String.DefaultResponseCreator
body(Resource resource)
Set the body as aResource
.DefaultResponseCreator
contentType(MediaType mediaType)
Set theContent-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 theLocation
header.
构造器详细资料
DefaultResponseCreator
protected DefaultResponseCreator(HttpStatus statusCode)
Protected constructor. Use static factory methods inMockRestResponseCreators
.
方法详细资料
body
public DefaultResponseCreator body(String content)
Set the body as a UTF-8 String.
body
public DefaultResponseCreator body(byte[] content)
Set the body as a byte array.
body
public DefaultResponseCreator body(Resource resource)
Set the body as aResource
.
contentType
public DefaultResponseCreator contentType(MediaType mediaType)
Set theContent-Type
header.
location
public DefaultResponseCreator location(URI location)
Set theLocation
header.
headers
public DefaultResponseCreator headers(HttpHeaders headers)
Copy all given headers.
createResponse
public ClientHttpResponse createResponse(ClientHttpRequest request) throws IOException
从接口复制的说明:ResponseCreator
Create a response for the given request.- 指定者:
createResponse
在接口中ResponseCreator
- 参数:
request
- the request- 抛出:
IOException