public class MockServerHttpResponse extends Object implements ServerHttpResponse
ServerHttpResponse
.Constructor and Description |
---|
MockServerHttpResponse() |
Modifier and Type | Method and Description |
---|---|
void |
beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
Register an action to be applied just before the message is committed.
|
DataBufferFactory |
bufferFactory()
Return a
DataBufferFactory that can be used for creating the body. |
org.reactivestreams.Publisher<DataBuffer> |
getBody() |
org.reactivestreams.Publisher<org.reactivestreams.Publisher<DataBuffer>> |
getBodyWithFlush() |
MultiValueMap<String,ResponseCookie> |
getCookies()
Return a mutable map with the cookies to send to the server.
|
HttpHeaders |
getHeaders()
Return the headers of this message.
|
HttpStatus |
getStatusCode()
Return the HTTP status code or
null if not set. |
reactor.core.publisher.Mono<Void> |
setComplete()
Indicate that request 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 server response (if not
applied already). |
boolean |
setStatusCode(HttpStatus status)
Set the HTTP status code of the response.
|
reactor.core.publisher.Mono<Void> |
writeAndFlushWith(org.reactivestreams.Publisher<org.reactivestreams.Publisher<DataBuffer>> body)
Use the given
Publisher of Publishers to write the body of the
message to the underlying HTTP layer, flushing after each
Publisher<DataBuffer> . |
reactor.core.publisher.Mono<Void> |
writeWith(org.reactivestreams.Publisher<DataBuffer> body)
Use the given
Publisher to write the body of the message to the underlying
HTTP layer. |
public boolean setStatusCode(HttpStatus status)
ServerHttpResponse
setStatusCode
in interface ServerHttpResponse
status
- the HTTP status as an HttpStatus
enum valuefalse
if the status code has not been set because the HTTP response
is already committed, true
if it has been set correctly.public HttpStatus getStatusCode()
ServerHttpResponse
null
if not set.getStatusCode
in interface ServerHttpResponse
public HttpHeaders getHeaders()
HttpMessage
getHeaders
in interface HttpMessage
null
)public MultiValueMap<String,ResponseCookie> getCookies()
ServerHttpResponse
getCookies
in interface ServerHttpResponse
public org.reactivestreams.Publisher<DataBuffer> getBody()
public org.reactivestreams.Publisher<org.reactivestreams.Publisher<DataBuffer>> getBodyWithFlush()
public reactor.core.publisher.Mono<Void> writeWith(org.reactivestreams.Publisher<DataBuffer> body)
ReactiveHttpOutputMessage
Publisher
to write the body of the message to the underlying
HTTP layer.writeWith
in interface ReactiveHttpOutputMessage
body
- the body content publisherMono
that indicates completion or errorpublic reactor.core.publisher.Mono<Void> writeAndFlushWith(org.reactivestreams.Publisher<org.reactivestreams.Publisher<DataBuffer>> body)
ReactiveHttpOutputMessage
Publisher
of Publishers
to write the body of the
message to the underlying HTTP layer, flushing after each
Publisher<DataBuffer>
.writeAndFlushWith
in interface ReactiveHttpOutputMessage
body
- the body content publisherMono
that indicates completion or errorpublic void beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
ReactiveHttpOutputMessage
beforeCommit
in interface ReactiveHttpOutputMessage
action
- the actionpublic reactor.core.publisher.Mono<Void> setComplete()
ServerHttpResponse
HttpMessage.getHeaders()
to the underlying server response (if not
applied already).
This method should be automatically invoked at the end of request processing so typically applications should not have to invoke it. If invoked multiple times it should have no side effects.
setComplete
in interface ReactiveHttpOutputMessage
setComplete
in interface ServerHttpResponse
Mono
that indicates completion or errorpublic DataBufferFactory bufferFactory()
ReactiveHttpOutputMessage
DataBufferFactory
that can be used for creating the body.bufferFactory
in interface ReactiveHttpOutputMessage
ReactiveHttpOutputMessage.writeWith(Publisher)