Interface RoutingResponse

All Superinterfaces:
ServerResponse
All Known Implementing Classes:
ServerResponseBase

public interface RoutingResponse extends ServerResponse
Routing response of a server.
  • Method Details

    • resetRouting

      void resetRouting()
      Reset routing information (nexted, rerouted etc.).
    • shouldReroute

      boolean shouldReroute()
      Should we reroute this exchange.
      Returns:
      whether rerouting was requested
    • reroutePrologue

      HttpPrologue reroutePrologue(HttpPrologue prologue)
      A new, rerouted prologue.
      Parameters:
      prologue - current prologue
      Returns:
      prologue to use when rerouting
    • isNexted

      boolean isNexted()
      Whether this request is nexted (ServerResponse.next() was called).
      Returns:
      if nexted
    • hasEntity

      boolean hasEntity()
      Whether this request has an entity.
      Returns:
      whether has entity
    • automaticContentEncoding

      default RoutingResponse automaticContentEncoding(boolean enabled)
      Configure whether the WebServer response layer may automatically encode the response entity using the listener content encoding context. This does not remove or rewrite any explicitly configured Content-Encoding header. Repeated calls replace the previous setting until response content encoding is selected.
      Specified by:
      automaticContentEncoding in interface ServerResponse
      Parameters:
      enabled - whether automatic response content encoding is enabled
      Returns:
      this instance
      Throws:
      IllegalStateException - if response content encoding was already selected, or the response was sent
    • contentEncoder

      default RoutingResponse contentEncoder(ContentEncoder encoder)
      Configure an explicit response content encoder. Repeated calls replace the previous encoder until response content encoding is selected. The selected encoder's headers are applied once during selection.
      Specified by:
      contentEncoder in interface ServerResponse
      Parameters:
      encoder - content encoder
      Returns:
      this instance
      Throws:
      NullPointerException - if encoder is null
      IllegalStateException - if response content encoding was already selected, or the response was sent
    • reset

      boolean reset()
      Return true if the underlying response buffers and headers can be reset and a new response can be sent.
      Returns:
      true if reset was successful and a new response can be created instead of the existing one, false if reset failed and status and headers (and maybe entity bytes) were already sent
    • commit

      void commit()
      Commit the response. This is mostly useful for output stream based responses, where we may want to delay closing the output stream to handle errors, when route uses try with resources. After this method is called, response cannot be reset().
    • resetStream

      default boolean resetStream()
      Return true if the underlying response buffers can be reset and a new response can be sent.

      As opposed to reset(), this method is not expected to reset headers already configured on the response

      This method calls reset() by default.

      Returns:
      true if reset was successful and a new response can be created instead of the existing one, false if reset failed and status and headers (and maybe entity bytes) were already sent
    • resetEntity

      default boolean resetEntity()
      Reset the response entity so an unsent response can be replaced while preserving response metadata unrelated to the entity, such as CORS, cookies, cache controls, and Vary headers.

      This method is intended for Helidon infrastructure that replaces a failed response entity.

      Implementations that track entity metadata must override this method to reset entity buffers and remove framing, representation, validator, range, and trailer headers. Implementations with separate trailer state must reset that state as well. This method does not change the response status. An error handler that replaces the entity is responsible for configuring or deliberately retaining an appropriate status before sending the replacement response.

      For compatibility with existing RoutingResponse implementations, the default implementation calls resetStream().

      Returns:
      true if reset was successful and a new entity can be created instead of the existing one, false if reset failed and status and headers (and maybe entity bytes) were already sent
    • entityStreamFilter

      default void entityStreamFilter(UnaryOperator<OutputStream> filterFunction)
      Configure an infrastructure output stream filter associated with the current response entity.

      Implementations which distinguish entity-scoped filters remove the filter if error handling replaces the unsent entity. Application filters should use ServerResponse.streamFilter(UnaryOperator) so they also apply to a replacement error response. The default fallback registers the filter through the public method and therefore retains it.

      Parameters:
      filterFunction - function that wraps the response output stream
    • entityBeforeSend

      default void entityBeforeSend(Runnable listener)
      Register an infrastructure listener associated with the current response entity.

      Implementations which distinguish entity-scoped listeners remove the listener if error handling replaces the unsent entity. Application listeners should use ServerResponse.beforeSend(Runnable) so they also apply to a replacement error response. The default fallback registers the listener through the public method and therefore retains it.

      Parameters:
      listener - listener invoked before the response is sent