Class ServerResponseBase<T extends ServerResponseBase<T>>

java.lang.Object
io.helidon.webserver.http.ServerResponseBase<T>
Type Parameters:
T - type of the response extending this class to allow fluent API
All Implemented Interfaces:
RoutingResponse, ServerResponse

public abstract class ServerResponseBase<T extends ServerResponseBase<T>> extends Object implements RoutingResponse
Base class for common server response tasks that can be shared across HTTP versions.
  • Field Details

    • STREAM_RESULT_NAME

      protected static final HeaderName STREAM_RESULT_NAME
      Stream result trailer name.
    • STREAM_TRAILERS

      protected static final Header STREAM_TRAILERS
      Stream status trailers.
  • Constructor Details

    • ServerResponseBase

      protected ServerResponseBase(ConnectionContext ctx, ServerRequest request)
      Create server response.
      Parameters:
      ctx - context
      request - server request
  • Method Details

    • status

      public T status(Status status)
      Description copied from interface: ServerResponse
      Status of the response.
      Specified by:
      status in interface ServerResponse
      Parameters:
      status - HTTP status
      Returns:
      this instance
    • status

      public Status status()
      Description copied from interface: ServerResponse
      Configured HTTP status, if not configured, returns Status.OK_200.
      Specified by:
      status in interface ServerResponse
      Returns:
      status
    • send

      public void send()
      Description copied from interface: ServerResponse
      Send a response with no entity.
      Specified by:
      send in interface ServerResponse
    • send

      public void send(Object entity)
      Description copied from interface: ServerResponse
      Send an entity, a MediaContext will be used to serialize the entity.
      Specified by:
      send in interface ServerResponse
      Parameters:
      entity - entity object
    • whenSent

      public T whenSent(Runnable listener)
      Description copied from interface: ServerResponse
      Completed when last byte is buffered for socket write.
      Specified by:
      whenSent in interface ServerResponse
      Parameters:
      listener - listener to add to list of listeners that will be triggered once response is sent
      Returns:
      this instance
    • reroute

      public T reroute(String newPath)
      Description copied from interface: ServerResponse
      Re-route using a different path.
      Specified by:
      reroute in interface ServerResponse
      Parameters:
      newPath - new path to use
      Returns:
      this instance
    • reroute

      public T reroute(String path, UriQuery query)
      Description copied from interface: ServerResponse
      Re-route using a different path and query.
      Specified by:
      reroute in interface ServerResponse
      Parameters:
      path - new path
      query - new query
      Returns:
      this instance
      See Also:
    • next

      public T next()
      Description copied from interface: ServerResponse
      Continue processing with the next route (and if none found, return a Status.NOT_FOUND_404). If any entity method was called, this method will throw an exception.
      Specified by:
      next in interface ServerResponse
      Returns:
      this instance
    • resetRouting

      public void resetRouting()
      Description copied from interface: RoutingResponse
      Reset routing information (nexted, rerouted etc.).
      Specified by:
      resetRouting in interface RoutingResponse
    • shouldReroute

      public boolean shouldReroute()
      Description copied from interface: RoutingResponse
      Should we reroute this exchange.
      Specified by:
      shouldReroute in interface RoutingResponse
      Returns:
      whether rerouting was requested
    • reroutePrologue

      public HttpPrologue reroutePrologue(HttpPrologue prologue)
      Description copied from interface: RoutingResponse
      A new, rerouted prologue.
      Specified by:
      reroutePrologue in interface RoutingResponse
      Parameters:
      prologue - current prologue
      Returns:
      prologue to use when rerouting
    • isNexted

      public boolean isNexted()
      Description copied from interface: RoutingResponse
      Whether this request is nexted (ServerResponse.next() was called).
      Specified by:
      isNexted in interface RoutingResponse
      Returns:
      if nexted
    • mediaContext

      protected MediaContext mediaContext()
      Gets media context for this response.
      Returns:
      the media context
    • entityBytes

      protected byte[] entityBytes(byte[] configuredEntity)
      Entity bytes encoded using content encoding. Does not attempt encoding if entity is empty.
      Parameters:
      configuredEntity - plain bytes
      Returns:
      encoded bytes
    • contentEncode

      protected OutputStream contentEncode(OutputStream outputStream)
      Encode content using requested/default content encoder.
      Parameters:
      outputStream - output stream to write encoded data to
      Returns:
      output stream to write plain data to
    • afterSend

      protected void afterSend()
      Execute after send runnables.