Class EntityWriterBase<T>

java.lang.Object
io.helidon.http.media.EntityWriterBase<T>
Type Parameters:
T - type of the supported object
All Implemented Interfaces:
EntityWriter<T>

public abstract class EntityWriterBase<T> extends Object implements EntityWriter<T>
Base class for entity writers that care about charsets ands content types.
  • Constructor Details

    • EntityWriterBase

      protected EntityWriterBase(MediaSupportConfig config)
      Provide the media support config with default content type, and supported accepted media types.
      Parameters:
      config - Media Support configuration
  • Method Details

    • serverResponseContentTypeAndCharset

      protected Optional<Charset> serverResponseContentTypeAndCharset(Headers serverRequestHeaders, WritableHeaders<?> serverResponseHeaders)
      Configure server response content type and return charset to use.

      Server response content type is handled as follows:

      • If a content type is explicitly set, use it, and return its charset if configured
      • If the default content type contains charset, set it, and return its charset
      • Set the default content type and return an empty optional
      Parameters:
      serverRequestHeaders - server request header
      serverResponseHeaders - server response headers (to configure content type)
      Returns:
      charset to use to write the response, if it could be guessed
    • clientRequestContentTypeAndCharset

      protected Optional<Charset> clientRequestContentTypeAndCharset(WritableHeaders<?> clientRequestHeaders)
      Configure client request content type and return the charset to use.
      Parameters:
      clientRequestHeaders - client request header (to get or configure content type)
      Returns:
      charset to use to write the request, if configured