public interface HttpServerResponse extends NettyOutbound, HttpServerInfos
Modifier and Type | Method and Description |
---|---|
HttpServerResponse |
addCookie(Cookie cookie)
Adds an outbound cookie
|
HttpServerResponse |
addHeader(CharSequence name,
CharSequence value)
Adds an outbound HTTP header, appending the value if the header already exist.
|
HttpServerResponse |
chunkedTransfer(boolean chunked)
Sets Transfer-Encoding header
|
HttpServerResponse |
compression(boolean compress)
Enables/Disables compression handling (gzip/deflate) for the underlying response
|
boolean |
hasSentHeaders()
Returns true if headers and status have been sent to the client
|
HttpServerResponse |
header(CharSequence name,
CharSequence value)
Sets an outbound HTTP header, replacing any pre-existing value.
|
HttpServerResponse |
headers(HttpHeaders headers)
Sets outbound HTTP headers, replacing any pre-existing value for these headers.
|
HttpServerResponse |
keepAlive(boolean keepAlive)
Sets the request
keepAlive if true otherwise remove the existing connection keep alive header |
HttpHeaders |
responseHeaders()
Returns the outbound HTTP headers, sent back to the clients
|
Mono<Void> |
send()
Sends the HTTP headers and empty content thus delimiting a full empty body http response.
|
NettyOutbound |
sendHeaders()
Returns a
NettyOutbound successful on committed response |
Mono<Void> |
sendNotFound()
Sends 404 status
HttpResponseStatus.NOT_FOUND . |
Mono<Void> |
sendRedirect(String location)
Sends redirect status
HttpResponseStatus.FOUND along with a location
header to the remote client. |
default Mono<Void> |
sendWebsocket(BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> websocketHandler)
Upgrades the connection to websocket.
|
Mono<Void> |
sendWebsocket(BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> websocketHandler,
WebsocketServerSpec websocketServerSpec)
Upgrades the connection to websocket.
|
HttpServerResponse |
sse()
Adds "text/event-stream" content-type for Server-Sent Events
|
HttpResponseStatus |
status()
Returns the assigned HTTP status
|
HttpServerResponse |
status(HttpResponseStatus status)
Sets an HTTP status to be sent along with the headers
|
default HttpServerResponse |
status(int status)
Sets an HTTP status to be sent along with the headers
|
HttpServerResponse |
trailerHeaders(Consumer<? super HttpHeaders> trailerHeaders)
Callback for setting outbound trailer headers.
|
HttpServerResponse |
withConnection(Consumer<? super Connection> withConnection)
Call the passed callback with a
Connection to operate on the underlying
Channel state. |
alloc, neverComplete, send, send, sendByteArray, sendFile, sendFile, sendFileChunked, sendGroups, sendObject, sendObject, sendObject, sendString, sendString, sendUsing, subscribe, then, then, then
allCookies
cookies, fullPath, isKeepAlive, isWebsocket, method, path, requestId, uri, version
HttpServerResponse addCookie(Cookie cookie)
HttpServerResponse
HttpServerResponse addHeader(CharSequence name, CharSequence value)
name
- header namevalue
- header valueHttpServerResponse
HttpServerResponse chunkedTransfer(boolean chunked)
chunked
- true if Transfer-Encoding: chunkedHttpServerResponse
HttpServerResponse withConnection(Consumer<? super Connection> withConnection)
NettyOutbound
Connection
to operate on the underlying
Channel
state.withConnection
in interface NettyOutbound
withConnection
- connection callbackConnection
HttpServerResponse compression(boolean compress)
compress
- should handle compressionHttpServerResponse
boolean hasSentHeaders()
HttpServerResponse header(CharSequence name, CharSequence value)
name
- headers keyvalue
- header valueHttpServerResponse
HttpServerResponse headers(HttpHeaders headers)
headers
- netty headers mapHttpServerResponse
HttpServerResponse keepAlive(boolean keepAlive)
keepAlive
if true otherwise remove the existing connection keep alive headerHttpServerResponse
HttpHeaders responseHeaders()
Mono<Void> send()
Mono
successful on committed responseNettyOutbound.send(Publisher)
NettyOutbound sendHeaders()
NettyOutbound
successful on committed responseNettyOutbound
successful on committed responseMono<Void> sendNotFound()
HttpResponseStatus.NOT_FOUND
.Mono
successful on flush confirmationMono<Void> sendRedirect(String location)
HttpResponseStatus.FOUND
along with a location
header to the remote client.location
- the location to redirect toMono
successful on flush confirmationdefault Mono<Void> sendWebsocket(BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> websocketHandler)
Mono
completing when the upgrade
is confirmed, then the provided callback is invoked, if the upgrade is not
successful the returned Mono
fails.websocketHandler
- the I/O handler for websocket transportMono
completing when upgrade is confirmed, otherwise failsMono<Void> sendWebsocket(BiFunction<? super WebsocketInbound,? super WebsocketOutbound,? extends Publisher<Void>> websocketHandler, WebsocketServerSpec websocketServerSpec)
Mono
completing when the upgrade
is confirmed, then the provided callback is invoked, if the upgrade is not
successful the returned Mono
fails.websocketHandler
- the I/O handler for websocket transportwebsocketServerSpec
- WebsocketServerSpec
for websocket configurationMono
completing when upgrade is confirmed, otherwise failsHttpServerResponse sse()
HttpServerResponse
HttpResponseStatus status()
HttpServerResponse status(HttpResponseStatus status)
status
- an HTTP status to be sent along with the headersHttpServerResponse
default HttpServerResponse status(int status)
status
- an HTTP status to be sent along with the headersHttpServerResponse
HttpServerResponse trailerHeaders(Consumer<? super HttpHeaders> trailerHeaders)
Note:Only headers names declared with HttpHeaderNames.TRAILER
are accepted.
Note:Trailer headers are sent only when a message body is encoded with the chunked transfer coding
Note:The headers below cannot be sent as trailer headers:
trailerHeaders
- netty headers mapHttpServerResponse