public abstract class AbstractServerHttpResponse extends Object implements ServerHttpResponse
ServerHttpResponse
implementations.Constructor and Description |
---|
AbstractServerHttpResponse(org.springframework.core.io.buffer.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.
|
org.springframework.core.io.buffer.DataBufferFactory |
bufferFactory()
Return a
DataBufferFactory that can be used for creating the body. |
org.springframework.util.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<org.springframework.core.io.buffer.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<org.springframework.core.io.buffer.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<org.springframework.core.io.buffer.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<org.springframework.core.io.buffer.DataBuffer> body)
Implement this method to write to the underlying the response.
|
public AbstractServerHttpResponse(org.springframework.core.io.buffer.DataBufferFactory dataBufferFactory)
public final org.springframework.core.io.buffer.DataBufferFactory bufferFactory()
ReactiveHttpOutputMessage
DataBufferFactory
that can be used for creating the body.bufferFactory
in interface ReactiveHttpOutputMessage
ReactiveHttpOutputMessage.writeWith(Publisher)
public boolean setStatusCode(HttpStatus statusCode)
ServerHttpResponse
setStatusCode
in interface ServerHttpResponse
statusCode
- 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 org.springframework.util.MultiValueMap<String,ResponseCookie> getCookies()
ServerHttpResponse
getCookies
in interface ServerHttpResponse
public void beforeCommit(Supplier<? extends reactor.core.publisher.Mono<Void>> action)
ReactiveHttpOutputMessage
beforeCommit
in interface ReactiveHttpOutputMessage
action
- the actionpublic final reactor.core.publisher.Mono<Void> writeWith(org.reactivestreams.Publisher<org.springframework.core.io.buffer.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 final reactor.core.publisher.Mono<Void> writeAndFlushWith(org.reactivestreams.Publisher<org.reactivestreams.Publisher<org.springframework.core.io.buffer.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 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 errorprotected reactor.core.publisher.Mono<Void> applyBeforeCommit()
protected abstract reactor.core.publisher.Mono<Void> writeWithInternal(org.reactivestreams.Publisher<org.springframework.core.io.buffer.DataBuffer> body)
body
- the publisher to write withprotected abstract reactor.core.publisher.Mono<Void> writeAndFlushWithInternal(org.reactivestreams.Publisher<org.reactivestreams.Publisher<org.springframework.core.io.buffer.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.