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