Interface SinkProviderContext


public interface SinkProviderContext
A context for SinkProviders supplied at creation time.
  • Method Details

    • serverResponse

      ServerResponse serverResponse()
      Obtains the server response associated with this context.
      Returns:
      the server response
    • serverRequest

      default ServerRequest serverRequest()
      Obtains the server request associated with this context.
      Returns:
      the server response
    • connectionContext

      ConnectionContext connectionContext()
      Obtains access to the connection context.
      Returns:
      the connection context
    • entityOutputStream

      default Optional<OutputStream> entityOutputStream(Runnable responsePreparation)
      Entity output stream supplied by protocols that cannot expose the connection data writer directly to a sink provider.

      An empty result indicates that the sink provider must use the connection data writer. When present, the protocol supplies the fully decorated response entity stream, including response filters and content encoding, and the sink provider is responsible for closing it. The sink provider must write unencoded entity bytes and must not apply these transformations again.

      A protocol that supplies an entity stream invokes responsePreparation exactly once, after ServerResponse.beforeSend(Runnable) listeners and before constructing response filters or content encoding. If response preparation fails, the protocol must not construct or return an entity stream. An implementation that returns an empty result does not invoke responsePreparation.

      The sink provider must close the stream before invoking closeRunnable() so stream wrappers can write their final bytes before the protocol response is committed.

      Parameters:
      responsePreparation - final response preparation
      Returns:
      entity output stream, or an empty optional if the protocol does not provide one
    • flushHeaders

      default void flushHeaders()
      Flushes final response headers while keeping the entity output stream open.

      Protocols returning a stream from entityOutputStream(Runnable) must override this method so headers can be sent before the first entity byte.

    • closeRunnable

      Runnable closeRunnable()
      Runnable to execute to close the response.
      Returns:
      the close runnable