Interface ResponseHeaders

All Superinterfaces:
ClientResponseHeaders, Headers, Iterable<Http.HeaderValue>, ServerResponseHeaders, WritableHeaders<ServerResponseHeaders>

public interface ResponseHeaders extends ServerResponseHeaders
Extends ServerResponseHeaders interface by adding HTTP response headers oriented constants and convenient methods. Use constants located in Http.Header as standard header names.

Lifecycle

Headers can be muted until send to the client. It is also possible to register a 'before send' function which can made 'last minute mutation'.

Headers are send together with HTTP status code also automatically just before first chunk of response data is send.

See Also:
  • Method Details

    • beforeSend

      void beforeSend(Consumer<ResponseHeaders> headersConsumer)
      Register a Consumer which is executed just before headers are send. Consumer can made 'last minute changes' in headers.

      Sending of headers to the client is postponed after all registered consumers are finished.

      There is no guarantied execution order.

      Parameters:
      headersConsumer - a consumer which will be executed just before headers are send.
    • whenSent

      Single<ResponseHeaders> whenSent()
      Returns a Single which is completed when all headers are sent to the client.
      Returns:
      a single of the headers
    • send

      Send headers and status code to the client. This instance become immutable after that (all muting methods throws IllegalStateException).

      It is non-blocking method returning a Single.

      Returns:
      a completion stage of sending process.