Package reactor.netty.http.server
Interface HttpServerResponse
- All Superinterfaces:
ConnectionInformation,HttpInfos,HttpServerInfos,NettyOutbound,Publisher<Void>
An Http Reactive Channel with several accessors related to HTTP flow: headers, params,
URI, method, websocket...
- Since:
- 0.5
- Author:
- Stephane Maldini
-
Method Summary
Modifier and TypeMethodDescriptionAdds an outbound cookie.addHeader(CharSequence name, CharSequence value) Adds an outbound HTTP header, appending the value if the header already exist.chunkedTransfer(boolean chunked) Sets Transfer-Encoding header.compression(boolean compress) Enables/Disables compression handling (gzip/deflate) for the underlying response.booleanReturns true if headers and status have been sent to the client.header(CharSequence name, CharSequence value) Sets an outbound HTTP header, replacing any pre-existing value.headers(HttpHeaders headers) Sets outbound HTTP headers, replacing any pre-existing value for these headers.keepAlive(boolean keepAlive) Sets the requestkeepAliveif true otherwise remove the existing connection keep alive header.Returns the outbound HTTP headers, sent back to the clients.send()Sends the HTTP headers and empty content thus delimiting a full empty body http response.Returns aNettyOutboundsuccessful on committed response.Sends 404 statusHttpResponseStatus.NOT_FOUND.sendRedirect(String location) Sends redirect statusHttpResponseStatus.FOUNDalong with a location header to the remote client.sendWebsocket(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> websocketHandler) Upgrades the connection to websocket.sendWebsocket(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> websocketHandler, WebsocketServerSpec websocketServerSpec) Upgrades the connection to websocket.sse()Adds "text/event-stream" content-type for Server-Sent Events.status()Returns the assigned HTTP status.default HttpServerResponsestatus(int status) Sets an HTTP status to be sent along with the headers.status(HttpResponseStatus status) Sets an HTTP status to be sent along with the headers.trailerHeaders(Consumer<? super HttpHeaders> trailerHeaders) Callback for setting outbound trailer headers.withConnection(Consumer<? super Connection> withConnection) Call the passed callback with aConnectionto operate on the underlyingChannelstate.Methods inherited from interface reactor.netty.http.server.ConnectionInformation
connectionHostAddress, connectionRemoteAddress, connectionScheme, hostAddress, hostName, hostPort, remoteAddress, schemeMethods inherited from interface reactor.netty.http.HttpInfos
cookies, fullPath, isKeepAlive, isWebsocket, method, path, requestId, uri, versionMethods inherited from interface reactor.netty.http.server.HttpServerInfos
allCookiesMethods inherited from interface reactor.netty.NettyOutbound
alloc, neverComplete, send, send, sendByteArray, sendFile, sendFile, sendFileChunked, sendGroups, sendObject, sendObject, sendObject, sendString, sendString, sendUsing, subscribe, then, then, then
-
Method Details
-
addCookie
Adds an outbound cookie.- Returns:
- this
HttpServerResponse
-
addHeader
Adds an outbound HTTP header, appending the value if the header already exist.- Parameters:
name- header namevalue- header value- Returns:
- this
HttpServerResponse
-
chunkedTransfer
Sets Transfer-Encoding header.- Parameters:
chunked- true if Transfer-Encoding: chunked- Returns:
- this
HttpServerResponse
-
withConnection
Description copied from interface:NettyOutboundCall the passed callback with aConnectionto operate on the underlyingChannelstate.- Specified by:
withConnectionin interfaceNettyOutbound- Parameters:
withConnection- connection callback- Returns:
- the
Connection
-
compression
Enables/Disables compression handling (gzip/deflate) for the underlying response.- Parameters:
compress- should handle compression- Returns:
- this
HttpServerResponse
-
hasSentHeaders
boolean hasSentHeaders()Returns true if headers and status have been sent to the client.- Returns:
- true if headers and status have been sent to the client
-
header
Sets an outbound HTTP header, replacing any pre-existing value.- Parameters:
name- headers keyvalue- header value- Returns:
- this
HttpServerResponse
-
headers
Sets outbound HTTP headers, replacing any pre-existing value for these headers.- Parameters:
headers- netty headers map- Returns:
- this
HttpServerResponse
-
keepAlive
Sets the requestkeepAliveif true otherwise remove the existing connection keep alive header.- Returns:
- this
HttpServerResponse
-
responseHeaders
HttpHeaders responseHeaders()Returns the outbound HTTP headers, sent back to the clients.- Returns:
- headers sent back to the clients
-
send
Sends the HTTP headers and empty content thus delimiting a full empty body http response.- Returns:
- a
Monosuccessful on committed response - See Also:
-
sendHeaders
NettyOutbound sendHeaders()Returns aNettyOutboundsuccessful on committed response.- Returns:
- a
NettyOutboundsuccessful on committed response
-
sendNotFound
Sends 404 statusHttpResponseStatus.NOT_FOUND.- Returns:
- a
Monosuccessful on flush confirmation
-
sendRedirect
Sends redirect statusHttpResponseStatus.FOUNDalong with a location header to the remote client.- Parameters:
location- the location to redirect to- Returns:
- a
Monosuccessful on flush confirmation
-
sendWebsocket
default Mono<Void> sendWebsocket(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> websocketHandler) Upgrades the connection to websocket. AMonocompleting when the upgrade is confirmed, then the provided callback is invoked, if the upgrade is not successful the returnedMonofails.- Parameters:
websocketHandler- the I/O handler for websocket transport- Returns:
- a
Monocompleting when upgrade is confirmed, otherwise fails
-
sendWebsocket
Mono<Void> sendWebsocket(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> websocketHandler, WebsocketServerSpec websocketServerSpec) Upgrades the connection to websocket. AMonocompleting when the upgrade is confirmed, then the provided callback is invoked, if the upgrade is not successful the returnedMonofails.- Parameters:
websocketHandler- the I/O handler for websocket transportwebsocketServerSpec-WebsocketServerSpecfor websocket configuration- Returns:
- a
Monocompleting when upgrade is confirmed, otherwise fails - Since:
- 0.9.5
-
sse
HttpServerResponse sse()Adds "text/event-stream" content-type for Server-Sent Events.- Returns:
- this
HttpServerResponse
-
status
HttpResponseStatus status()Returns the assigned HTTP status.- Returns:
- the assigned HTTP status
-
status
Sets an HTTP status to be sent along with the headers.- Parameters:
status- an HTTP status to be sent along with the headers- Returns:
- this
HttpServerResponse
-
status
Sets an HTTP status to be sent along with the headers.- Parameters:
status- an HTTP status to be sent along with the headers- Returns:
- this
HttpServerResponse
-
trailerHeaders
Callback for setting outbound trailer headers. The callback is invoked when the response is about to be completed.Note:Only headers names declared with
HttpHeaderNames.TRAILERare 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:
- Age
- Cache-Control
- Content-Encoding
- Content-Length
- Content-Range
- Content-Type
- Date
- Expires
- Location
- Retry-After
- Trailer
- Transfer-Encoding
- Vary
- Warning
- Parameters:
trailerHeaders- netty headers map- Returns:
- this
HttpServerResponse - Since:
- 1.0.12
-