Interface HttpServerResponse

All Superinterfaces:
ConnectionInformation, HttpInfos, HttpServerInfos, NettyOutbound, Publisher<Void>

public interface HttpServerResponse extends NettyOutbound, HttpServerInfos
An Http Reactive Channel with several accessors related to HTTP flow: headers, params, URI, method, websocket...
Since:
0.5
Author:
Stephane Maldini
  • Method Details

    • addCookie

      HttpServerResponse addCookie(Cookie cookie)
      Adds an outbound cookie.
      Returns:
      this HttpServerResponse
    • addHeader

      HttpServerResponse addHeader(CharSequence name, CharSequence value)
      Adds an outbound HTTP header, appending the value if the header already exist.
      Parameters:
      name - header name
      value - header value
      Returns:
      this HttpServerResponse
    • chunkedTransfer

      HttpServerResponse chunkedTransfer(boolean chunked)
      Sets Transfer-Encoding header.
      Parameters:
      chunked - true if Transfer-Encoding: chunked
      Returns:
      this HttpServerResponse
    • withConnection

      HttpServerResponse withConnection(Consumer<? super Connection> withConnection)
      Description copied from interface: NettyOutbound
      Call the passed callback with a Connection to operate on the underlying Channel state.
      Specified by:
      withConnection in interface NettyOutbound
      Parameters:
      withConnection - connection callback
      Returns:
      the Connection
    • compression

      HttpServerResponse compression(boolean compress)
      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 key
      value - header value
      Returns:
      this HttpServerResponse
    • headers

      HttpServerResponse headers(HttpHeaders headers)
      Sets outbound HTTP headers, replacing any pre-existing value for these headers.
      Parameters:
      headers - netty headers map
      Returns:
      this HttpServerResponse
    • keepAlive

      HttpServerResponse keepAlive(boolean keepAlive)
      Sets the request keepAlive if 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

      Mono<Void> send()
      Sends the HTTP headers and empty content thus delimiting a full empty body http response.
      Returns:
      a Mono successful on committed response
      See Also:
    • sendHeaders

      NettyOutbound sendHeaders()
      Returns a NettyOutbound successful on committed response.
      Returns:
      a NettyOutbound successful on committed response
    • sendNotFound

      Mono<Void> sendNotFound()
      Returns:
      a Mono successful on flush confirmation
    • sendRedirect

      Mono<Void> sendRedirect(String location)
      Sends redirect status HttpResponseStatus.FOUND along with a location header to the remote client.
      Parameters:
      location - the location to redirect to
      Returns:
      a Mono successful on flush confirmation
    • sendWebsocket

      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 - the I/O handler for websocket transport
      Returns:
      a Mono completing 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. 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 - the I/O handler for websocket transport
      websocketServerSpec - WebsocketServerSpec for websocket configuration
      Returns:
      a Mono completing when upgrade is confirmed, otherwise fails
      Since:
      0.9.5
    • sse

      Adds "text/event-stream" content-type for Server-Sent Events.
      Returns:
      this HttpServerResponse
    • 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

      default HttpServerResponse status(int 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

      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 - netty headers map
      Returns:
      this HttpServerResponse
      Since:
      1.0.12