public abstract class AbstractServerHttpResponse extends Object implements ServerHttpResponse
ServerHttpResponse implementations.| Constructor and Description |
|---|
AbstractServerHttpResponse(DataBufferFactory dataBufferFactory) |
| Modifier and Type | Method and Description |
|---|---|
protected reactor.core.publisher.Mono<Void> |
applyBeforeCommit() |
void |
beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
Register an action to be applied just before the message is committed.
|
DataBufferFactory |
bufferFactory()
Returns a
DataBufferFactory that can be used for creating the body. |
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 statusCode)
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>. |
protected abstract reactor.core.publisher.Mono<Void> |
writeAndFlushWithInternal(org.reactivestreams.Publisher<org.reactivestreams.Publisher<DataBuffer>> body)
Implement this method to write to the underlying the response, and flush after
each
Publisher<DataBuffer>. |
protected abstract void |
writeCookies()
Implement this method to add cookies from
getHeaders() to the
underlying response. |
protected abstract void |
writeHeaders()
Implement this method to apply header changes from
getHeaders()
to the underlying response. |
protected abstract void |
writeStatusCode()
Implement this method to write the status code to the underlying response.
|
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. |
protected abstract reactor.core.publisher.Mono<Void> |
writeWithInternal(org.reactivestreams.Publisher<DataBuffer> body)
Implement this method to write to the underlying the response.
|
public AbstractServerHttpResponse(DataBufferFactory dataBufferFactory)
public final DataBufferFactory bufferFactory()
ReactiveHttpOutputMessageDataBufferFactory that can be used for creating the body.bufferFactory in interface ReactiveHttpOutputMessageReactiveHttpOutputMessage.writeWith(Publisher)public boolean setStatusCode(HttpStatus statusCode)
ServerHttpResponsesetStatusCode in interface ServerHttpResponsestatusCode - 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()
ServerHttpResponsenull if not set.getStatusCode in interface ServerHttpResponsepublic HttpHeaders getHeaders()
HttpMessagegetHeaders in interface HttpMessagenull)public MultiValueMap<String,ResponseCookie> getCookies()
ServerHttpResponsegetCookies in interface ServerHttpResponsepublic void beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
ReactiveHttpOutputMessagebeforeCommit in interface ReactiveHttpOutputMessageaction - the actionpublic final reactor.core.publisher.Mono<Void> writeWith(org.reactivestreams.Publisher<DataBuffer> body)
ReactiveHttpOutputMessagePublisher to write the body of the message to the underlying
HTTP layer.writeWith in interface ReactiveHttpOutputMessagebody - the body content publisherpublic final reactor.core.publisher.Mono<Void> writeAndFlushWith(org.reactivestreams.Publisher<org.reactivestreams.Publisher<DataBuffer>> body)
ReactiveHttpOutputMessagePublisher of Publishers to write the body of the
message to the underlying HTTP layer, flushing after each
Publisher<DataBuffer>.writeAndFlushWith in interface ReactiveHttpOutputMessagebody - the body content publisherprotected reactor.core.publisher.Mono<Void> applyBeforeCommit()
protected abstract reactor.core.publisher.Mono<Void> writeWithInternal(org.reactivestreams.Publisher<DataBuffer> body)
body - the publisher to write withprotected abstract reactor.core.publisher.Mono<Void> writeAndFlushWithInternal(org.reactivestreams.Publisher<org.reactivestreams.Publisher<DataBuffer>> body)
Publisher<DataBuffer>.body - the publisher to write and flush withprotected abstract void writeStatusCode()
protected abstract void writeHeaders()
getHeaders()
to the underlying response. This method is called once only.protected abstract void writeCookies()
getHeaders() to the
underlying response. This method is called once only.public reactor.core.publisher.Mono<Void> setComplete()
ServerHttpResponseHttpMessage.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 ReactiveHttpOutputMessagesetComplete in interface ServerHttpResponse