类 MockServerHttpResponse
java.lang.Object
cn.taketoday.http.server.reactive.AbstractServerHttpResponse
cn.taketoday.mock.http.server.reactive.MockServerHttpResponse
- 所有已实现的接口:
cn.taketoday.http.HttpMessage,cn.taketoday.http.ReactiveHttpOutputMessage,cn.taketoday.http.server.reactive.ServerHttpResponse
public class MockServerHttpResponse
extends cn.taketoday.http.server.reactive.AbstractServerHttpResponse
Mock extension of
AbstractServerHttpResponse for use in tests without
an actual server.
By default response content is consumed in full upon writing and cached
for subsequent access, however it is also possible to set a custom
writeHandler.
- 从以下版本开始:
- 4.0
- 作者:
- Rossen Stoyanchev
-
字段概要
字段 -
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidprotected voidprotected voidreactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>getBody()Return the response body or an error stream if the body was not set.reactor.core.publisher.Mono<String>Aggregate response data and convert to a String using the "Content-Type" charset or "UTF-8" by default.<T> Treactor.core.publisher.Mono<Void>voidsetWriteHandler(Function<reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>, reactor.core.publisher.Mono<Void>> writeHandler) Configure a custom handler to consume the response body.protected reactor.core.publisher.Mono<Void>writeAndFlushWithInternal(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer>> body) protected reactor.core.publisher.Mono<Void>writeWithInternal(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body) 从类继承的方法 cn.taketoday.http.server.reactive.AbstractServerHttpResponse
addCookie, beforeCommit, bufferFactory, doCommit, doCommit, getCookies, getHeaders, getRawStatusCode, getStatusCode, isCommitted, setRawStatusCode, setStatusCode, touchDataBuffer, writeAndFlushWith, writeWith
-
字段详细资料
-
body
private reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer> body -
writeHandler
-
-
构造器详细资料
-
MockServerHttpResponse
public MockServerHttpResponse() -
MockServerHttpResponse
public MockServerHttpResponse(cn.taketoday.core.io.buffer.DataBufferFactory dataBufferFactory)
-
-
方法详细资料
-
setWriteHandler
public void setWriteHandler(Function<reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer>, reactor.core.publisher.Mono<Void>> writeHandler) Configure a custom handler to consume the response body.By default, response body content is consumed in full and cached for subsequent access in tests. Use this option to take control over how the response body is consumed.
- 参数:
writeHandler- the write handler to use returningMono<Void>when the body has been "written" (i.e. consumed).
-
getNativeResponse
public <T> T getNativeResponse()- 指定者:
getNativeResponse在类中cn.taketoday.http.server.reactive.AbstractServerHttpResponse
-
applyStatusCode
protected void applyStatusCode()- 指定者:
applyStatusCode在类中cn.taketoday.http.server.reactive.AbstractServerHttpResponse
-
applyHeaders
protected void applyHeaders()- 指定者:
applyHeaders在类中cn.taketoday.http.server.reactive.AbstractServerHttpResponse
-
applyCookies
protected void applyCookies()- 指定者:
applyCookies在类中cn.taketoday.http.server.reactive.AbstractServerHttpResponse
-
writeWithInternal
protected reactor.core.publisher.Mono<Void> writeWithInternal(org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer> body) - 指定者:
writeWithInternal在类中cn.taketoday.http.server.reactive.AbstractServerHttpResponse
-
writeAndFlushWithInternal
protected reactor.core.publisher.Mono<Void> writeAndFlushWithInternal(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends cn.taketoday.core.io.buffer.DataBuffer>> body) - 指定者:
writeAndFlushWithInternal在类中cn.taketoday.http.server.reactive.AbstractServerHttpResponse
-
setComplete
- 指定者:
setComplete在接口中cn.taketoday.http.ReactiveHttpOutputMessage- 覆盖:
setComplete在类中cn.taketoday.http.server.reactive.AbstractServerHttpResponse
-
getBody
public reactor.core.publisher.Flux<cn.taketoday.core.io.buffer.DataBuffer> getBody()Return the response body or an error stream if the body was not set. -
getBodyAsString
Aggregate response data and convert to a String using the "Content-Type" charset or "UTF-8" by default.
-