public class MockServerHttpResponse extends AbstractServerHttpResponse
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.
| Constructor and Description | 
|---|
| MockServerHttpResponse() | 
| MockServerHttpResponse(DataBufferFactory dataBufferFactory) | 
| Modifier and Type | Method and Description | 
|---|---|
| protected void | applyCookies()Add cookies from  AbstractServerHttpResponse.getHeaders()to the underlying response. | 
| protected void | applyHeaders()Invoked when the response is getting committed allowing subclasses to
 make apply header values to the underlying response. | 
| protected void | applyStatusCode()Write the status code to the underlying response. | 
| reactor.core.publisher.Flux<DataBuffer> | getBody()Return the response body or an error stream if the body was not set. | 
| reactor.core.publisher.Mono<String> | getBodyAsString()Aggregate response data and convert to a String using the "Content-Type"
 charset or "UTF-8" by default. | 
| <T> T | getNativeResponse()Return the underlying server response. | 
| reactor.core.publisher.Mono<Void> | setComplete()Indicate that message handling is complete, allowing for any cleanup or
 end-of-processing tasks to be performed such as applying header changes
 made via  HttpMessage.getHeaders()to the underlying HTTP message (if not
 applied already). | 
| void | setWriteHandler(Function<reactor.core.publisher.Flux<DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler)Configure a custom handler to consume the response body. | 
| protected reactor.core.publisher.Mono<Void> | writeAndFlushWithInternal(Publisher<? extends Publisher<? extends DataBuffer>> body)Write to the underlying the response, and flush after each  Publisher<DataBuffer>. | 
| protected reactor.core.publisher.Mono<Void> | writeWithInternal(Publisher<? extends DataBuffer> body)Write to the underlying the response. | 
addCookie, beforeCommit, bufferFactory, doCommit, doCommit, getCookies, getHeaders, getRawStatusCode, getStatusCode, getStatusCodeValue, isCommitted, setRawStatusCode, setStatusCode, setStatusCodeValue, touchDataBuffer, writeAndFlushWith, writeWithpublic MockServerHttpResponse()
public MockServerHttpResponse(DataBufferFactory dataBufferFactory)
public void setWriteHandler(Function<reactor.core.publisher.Flux<DataBuffer>,reactor.core.publisher.Mono<Void>> writeHandler)
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 returning Mono<Void>
 when the body has been "written" (i.e. consumed).public <T> T getNativeResponse()
AbstractServerHttpResponseNote: This is exposed mainly for internal framework use such as WebSocket upgrades in the spring-webflux module.
getNativeResponse in class AbstractServerHttpResponseprotected void applyStatusCode()
AbstractServerHttpResponseapplyStatusCode in class AbstractServerHttpResponseprotected void applyHeaders()
AbstractServerHttpResponseNote that most subclasses use an HttpHeaders instance that
 wraps an adapter to the native response headers such that changes are
 propagated to the underlying response on the go. That means this callback
 is typically not used other than for specialized updates such as setting
 the contentType or characterEncoding fields in a Servlet response.
applyHeaders in class AbstractServerHttpResponseprotected void applyCookies()
AbstractServerHttpResponseAbstractServerHttpResponse.getHeaders() to the underlying response.
 This method is called once only.applyCookies in class AbstractServerHttpResponseprotected reactor.core.publisher.Mono<Void> writeWithInternal(Publisher<? extends DataBuffer> body)
AbstractServerHttpResponsewriteWithInternal in class AbstractServerHttpResponsebody - the publisher to write withprotected reactor.core.publisher.Mono<Void> writeAndFlushWithInternal(Publisher<? extends Publisher<? extends DataBuffer>> body)
AbstractServerHttpResponsePublisher<DataBuffer>.writeAndFlushWithInternal in class AbstractServerHttpResponsebody - the publisher to write and flush withpublic reactor.core.publisher.Mono<Void> setComplete()
ReactiveHttpOutputMessageHttpMessage.getHeaders() to the underlying HTTP message (if not
 applied already).
 This method should be automatically invoked at the end of message processing so typically applications should not have to invoke it. If invoked multiple times it should have no side effects.
setComplete in interface ReactiveHttpOutputMessagesetComplete in class AbstractServerHttpResponseMono that indicates completion or errorpublic reactor.core.publisher.Flux<DataBuffer> getBody()
public reactor.core.publisher.Mono<String> getBodyAsString()