public class ServerHttpResponseDecorator extends Object implements ServerHttpResponse
ServerHttpResponse and delegates all methods to it.
Sub-classes can override specific methods selectively.| Constructor and Description |
|---|
ServerHttpResponseDecorator(ServerHttpResponse delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
addCookie(ResponseCookie cookie)
Add the given
ResponseCookie. |
void |
beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
Register an action to apply just before the HttpOutputMessage is committed.
|
DataBufferFactory |
bufferFactory()
Return a
DataBufferFactory that can be used to create the body. |
MultiValueMap<String,ResponseCookie> |
getCookies()
Return a mutable map with the cookies to send to the server.
|
ServerHttpResponse |
getDelegate() |
HttpHeaders |
getHeaders()
Return the headers of this message.
|
static <T> T |
getNativeResponse(ServerHttpResponse response)
Return the native response of the underlying server API, if possible,
also unwrapping
ServerHttpResponseDecorator if necessary. |
HttpStatus |
getStatusCode()
Return the status code that has been set, or otherwise fall back on the
status of the response from the underlying server.
|
boolean |
isCommitted()
Whether the HttpOutputMessage is committed.
|
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). |
boolean |
setStatusCode(HttpStatus status)
Set the HTTP status code of the response.
|
String |
toString() |
reactor.core.publisher.Mono<Void> |
writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends DataBuffer>> body)
Use the given
Publisher of Publishers to write the body
of the HttpOutputMessage to the underlying HTTP layer, flushing after
each Publisher<DataBuffer>. |
reactor.core.publisher.Mono<Void> |
writeWith(org.reactivestreams.Publisher<? extends DataBuffer> body)
Use the given
Publisher to write the body of the message to the
underlying HTTP layer. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetRawStatusCode, setRawStatusCodepublic ServerHttpResponseDecorator(ServerHttpResponse delegate)
public ServerHttpResponse getDelegate()
public boolean setStatusCode(@Nullable HttpStatus status)
ServerHttpResponsesetStatusCode in interface ServerHttpResponsestatus - the HTTP status as an HttpStatus enum valuefalse if the status code change wasn't processed because
the HTTP response is committed, true if successfully set.public HttpStatus getStatusCode()
ServerHttpResponsenull if the status code value is outside the
HttpStatus enum range, or if there is no default value from the
underlying server.getStatusCode in interface ServerHttpResponsepublic HttpHeaders getHeaders()
HttpMessagegetHeaders in interface HttpMessagenull)public MultiValueMap<String,ResponseCookie> getCookies()
ServerHttpResponsegetCookies in interface ServerHttpResponsepublic void addCookie(ResponseCookie cookie)
ServerHttpResponseResponseCookie.addCookie in interface ServerHttpResponsecookie - the cookie to addpublic DataBufferFactory bufferFactory()
ReactiveHttpOutputMessageDataBufferFactory that can be used to create the body.bufferFactory in interface ReactiveHttpOutputMessageReactiveHttpOutputMessage.writeWith(Publisher)public void beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
ReactiveHttpOutputMessageNote: the supplied action must be properly deferred,
e.g. via Mono.defer(java.util.function.Supplier<? extends reactor.core.publisher.Mono<? extends T>>) or Mono.fromRunnable(java.lang.Runnable), to ensure it's
executed in the right order, relative to other actions.
beforeCommit in interface ReactiveHttpOutputMessageaction - the action to applypublic boolean isCommitted()
ReactiveHttpOutputMessageisCommitted in interface ReactiveHttpOutputMessagepublic reactor.core.publisher.Mono<Void> writeWith(org.reactivestreams.Publisher<? extends DataBuffer> body)
ReactiveHttpOutputMessagePublisher to write the body of the message to the
underlying HTTP layer.writeWith in interface ReactiveHttpOutputMessagebody - the body content publisherMono that indicates completion or errorpublic reactor.core.publisher.Mono<Void> writeAndFlushWith(org.reactivestreams.Publisher<? extends org.reactivestreams.Publisher<? extends DataBuffer>> body)
ReactiveHttpOutputMessagePublisher of Publishers to write the body
of the HttpOutputMessage to the underlying HTTP layer, flushing after
each Publisher<DataBuffer>.writeAndFlushWith in interface ReactiveHttpOutputMessagebody - the body content publisherMono that indicates completion or errorpublic 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 ReactiveHttpOutputMessageMono that indicates completion or errorpublic static <T> T getNativeResponse(ServerHttpResponse response)
ServerHttpResponseDecorator if necessary.T - the expected native response typeresponse - the response to checkIllegalArgumentException - if the native response can't be obtained