Top Description Methods
reactor.netty5.http.server

public Interface HttpServerResponse

extends NettyOutbound, HttpServerInfos
Known Direct Implementers
reactor.netty5.http.server.HttpServerOperations
Imports
java.util.function.BiFunction, .Consumer, io.netty5.handler.codec.http.headers.HttpHeaders, .HttpSetCookie, io.netty5.handler.codec.http.HttpHeaderNames, .HttpResponseStatus, org.reactivestreams.Publisher, reactor.core.publisher.Mono, reactor.netty5.Connection, .NettyOutbound, reactor.netty5.http.websocket.WebsocketInbound, .WebsocketOutbound

An Http Reactive Channel with several accessors related to HTTP flow: headers, params, URI, method, websocket...
Author
Stephane Maldini
Since
0.5

Method Summary

Modifier and TypeMethod and Description
public HttpServerResponse

Returns:

this HttpServerResponse
addCookie
(HttpSetCookie cookie)

Adds an outbound cookie

public HttpServerResponse

Returns:

this HttpServerResponse
addHeader
(CharSequence
header name
name
,
CharSequence
header value
value
)

Adds an outbound HTTP header, appending the value if the header already exist.

public HttpServerResponse

Returns:

this HttpServerResponse
chunkedTransfer
(boolean
true if Transfer-Encoding: chunked
chunked
)

Sets Transfer-Encoding header

public HttpServerResponse

Returns:

this HttpServerResponse
compression
(boolean
should handle compression
compress
)

Enables/Disables compression handling (gzip/deflate) for the underlying response

public boolean

Returns:

true if headers and status have been sent to the client
hasSentHeaders
()

Returns true if headers and status have been sent to the client

public HttpServerResponse

Returns:

this HttpServerResponse
header
(CharSequence
headers key
name
,
CharSequence
header value
value
)

Sets an outbound HTTP header, replacing any pre-existing value.

public HttpServerResponse

Returns:

this HttpServerResponse
headers
(HttpHeaders
netty headers map
headers
)

Sets outbound HTTP headers, replacing any pre-existing value for these headers.

public HttpServerResponse

Returns:

this HttpServerResponse
keepAlive
(boolean keepAlive)

Sets the request keepAlive if true otherwise remove the existing connection keep alive header

public HttpHeaders

Returns:

headers sent back to the clients
responseHeaders
()

Returns the outbound HTTP headers, sent back to the clients

public Mono<Void>

Returns:

a Mono successful on committed response
send
()

Sends the HTTP headers and empty content thus delimiting a full empty body http response.

public NettyOutbound

Returns:

a NettyOutbound successful on committed response
sendHeaders
()

Returns a NettyOutbound successful on committed response

public Mono<Void>

Returns:

a Mono successful on flush confirmation
sendNotFound
()

Sends 404 status HttpResponseStatus#NOT_FOUND.

public Mono<Void>

Returns:

a Mono successful on flush confirmation
sendRedirect
(String
the location to redirect to
location
)

Sends redirect status HttpResponseStatus#FOUND along with a location header to the remote client.

public default Mono<Void>

Returns:

a Mono completing when upgrade is confirmed, otherwise fails
sendWebsocket
(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>>
the I/O handler for websocket transport
websocketHandler
)

Upgrades the connection to websocket.

public Mono<Void>

Returns:

a Mono completing when upgrade is confirmed, otherwise fails
sendWebsocket
(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>>
the I/O handler for websocket transport
websocketHandler
,
WebsocketServerSpec
WebsocketServerSpec for websocket configuration
websocketServerSpec
)

Upgrades the connection to websocket.

public HttpServerResponse

Returns:

this HttpServerResponse
sse
()

Adds "text/event-stream" content-type for Server-Sent Events

public HttpResponseStatus

Returns:

the assigned HTTP status
status
()

Returns the assigned HTTP status

public HttpServerResponse

Returns:

this HttpServerResponse
status
(HttpResponseStatus
an HTTP status to be sent along with the headers
status
)

Sets an HTTP status to be sent along with the headers

public default HttpServerResponse

Returns:

this HttpServerResponse
status
(int
an HTTP status to be sent along with the headers
status
)

Sets an HTTP status to be sent along with the headers

public HttpServerResponse

Returns:

this HttpServerResponse
trailerHeaders
(Consumer<? super HttpHeaders>
netty headers map
trailerHeaders
)

Callback for setting outbound trailer headers.

public HttpServerResponse
withConnection(Consumer<? super Connection>
connection callback
withConnection
)

Redeclares reactor.netty5.NettyOutbound.withConnection.

Call the passed callback with a Connection to operate on the underlying Channel state.
Inherited from reactor.netty5.http.server.HttpServerInfos:
allCookiescookies
Inherited from reactor.netty5.NettyOutbound:
allocneverCompletesendsendsendByteArraysendFilesendFilesendFileChunkedsendGroupssendObjectsendObjectsendObjectsendStringsendStringsendUsingsubscribethenthenthen

Method Detail

addCookieback to summary
public HttpServerResponse addCookie(HttpSetCookie cookie)

Adds an outbound cookie

Returns:HttpServerResponse

this HttpServerResponse

addHeaderback to summary
public HttpServerResponse addHeader(CharSequence name, CharSequence value)

Adds an outbound HTTP header, appending the value if the header already exist.

Parameters
name:CharSequence

header name

value:CharSequence

header value

Returns:HttpServerResponse

this HttpServerResponse

chunkedTransferback to summary
public HttpServerResponse chunkedTransfer(boolean chunked)

Sets Transfer-Encoding header

Parameters
chunked:boolean

true if Transfer-Encoding: chunked

Returns:HttpServerResponse

this HttpServerResponse

compressionback to summary
public HttpServerResponse compression(boolean compress)

Enables/Disables compression handling (gzip/deflate) for the underlying response

Parameters
compress:boolean

should handle compression

Returns:HttpServerResponse

this HttpServerResponse

hasSentHeadersback to summary
public boolean hasSentHeaders()

Returns true if headers and status have been sent to the client

Returns:boolean

true if headers and status have been sent to the client

headerback to summary
public HttpServerResponse header(CharSequence name, CharSequence value)

Sets an outbound HTTP header, replacing any pre-existing value.

Parameters
name:CharSequence

headers key

value:CharSequence

header value

Returns:HttpServerResponse

this HttpServerResponse

headersback to summary
public HttpServerResponse headers(HttpHeaders headers)

Sets outbound HTTP headers, replacing any pre-existing value for these headers.

Parameters
headers:HttpHeaders

netty headers map

Returns:HttpServerResponse

this HttpServerResponse

keepAliveback to summary
public HttpServerResponse keepAlive(boolean keepAlive)

Sets the request keepAlive if true otherwise remove the existing connection keep alive header

Returns:HttpServerResponse

this HttpServerResponse

responseHeadersback to summary
public HttpHeaders responseHeaders()

Returns the outbound HTTP headers, sent back to the clients

Returns:HttpHeaders

headers sent back to the clients

sendback to summary
public Mono<Void> send()

Sends the HTTP headers and empty content thus delimiting a full empty body http response.

Returns:Mono<Void>

a Mono successful on committed response

See Also
send(Publisher)
sendHeadersback to summary
public NettyOutbound sendHeaders()

Returns a NettyOutbound successful on committed response

Returns:NettyOutbound

a NettyOutbound successful on committed response

sendNotFoundback to summary
public Mono<Void> sendNotFound()

Sends 404 status HttpResponseStatus#NOT_FOUND.

Returns:Mono<Void>

a Mono successful on flush confirmation

sendRedirectback to summary
public Mono<Void> sendRedirect(String location)

Sends redirect status HttpResponseStatus#FOUND along with a location header to the remote client.

Parameters
location:String

the location to redirect to

Returns:Mono<Void>

a Mono successful on flush confirmation

sendWebsocketback to summary
public default Mono<Void> sendWebsocket(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> websocketHandler)

Upgrades the connection to websocket. A Mono completing when the upgrade is confirmed, then the provided callback is invoked, if the upgrade is not successful the returned Mono fails.

Parameters
websocketHandler:BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>>

the I/O handler for websocket transport

Returns:Mono<Void>

a Mono completing when upgrade is confirmed, otherwise fails

sendWebsocketback to summary
public Mono<Void> sendWebsocket(BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>> websocketHandler, WebsocketServerSpec websocketServerSpec)

Upgrades the connection to websocket. A Mono completing when the upgrade is confirmed, then the provided callback is invoked, if the upgrade is not successful the returned Mono fails.

Parameters
websocketHandler:BiFunction<? super WebsocketInbound, ? super WebsocketOutbound, ? extends Publisher<Void>>

the I/O handler for websocket transport

websocketServerSpec:WebsocketServerSpec

WebsocketServerSpec for websocket configuration

Returns:Mono<Void>

a Mono completing when upgrade is confirmed, otherwise fails

Since
0.9.5
sseback to summary
public HttpServerResponse sse()

Adds "text/event-stream" content-type for Server-Sent Events

Returns:HttpServerResponse

this HttpServerResponse

statusback to summary
public HttpResponseStatus status()

Returns the assigned HTTP status

Returns:HttpResponseStatus

the assigned HTTP status

statusback to summary
public HttpServerResponse status(HttpResponseStatus status)

Sets an HTTP status to be sent along with the headers

Parameters
status:HttpResponseStatus

an HTTP status to be sent along with the headers

Returns:HttpServerResponse

this HttpServerResponse

statusback to summary
public default HttpServerResponse status(int status)

Sets an HTTP status to be sent along with the headers

Parameters
status:int

an HTTP status to be sent along with the headers

Returns:HttpServerResponse

this HttpServerResponse

trailerHeadersback to summary
public HttpServerResponse trailerHeaders(Consumer<? super HttpHeaders> 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#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:

  • Age
  • Cache-Control
  • Content-Encoding
  • Content-Length
  • Content-Range
  • Content-Type
  • Date
  • Expires
  • Location
  • Retry-After
  • Trailer
  • Transfer-Encoding
  • Vary
  • Warning
Parameters
trailerHeaders:Consumer<? super HttpHeaders>

netty headers map

Returns:HttpServerResponse

this HttpServerResponse

Since
1.0.12
withConnectionback to summary
public HttpServerResponse withConnection(Consumer<? super Connection> withConnection)

Redeclares reactor.netty5.NettyOutbound.withConnection.

Doc from reactor.netty5.NettyOutbound.withConnection.

Call the passed callback with a Connection to operate on the underlying Channel state.

Parameters
withConnection:Consumer<? super Connection>

connection callback

Returns:HttpServerResponse

the Connection

Annotations
@Override