Interface ContentEncodingContext

All Superinterfaces:
RuntimeType.Api<ContentEncodingContextConfig>

public interface ContentEncodingContext extends RuntimeType.Api<ContentEncodingContextConfig>
Content encoding support to obtain encoders and decoders.
  • Method Details

    • create

      static ContentEncodingContext create()
      Create a new encoding support.
      Returns:
      content encoding support
    • create

      static ContentEncodingContext create(Config config)
      Create a new encoding support and apply provided configuration.
      Parameters:
      config - configuration to use
      Returns:
      content encoding support
    • create

      Create content encoding context from its prototype.
      Parameters:
      config - content encoding context configuration
      Returns:
      a new content encoding context
    • create

      Create media context, customizing its configuration.
      Parameters:
      consumer - consumer of media context builder
      Returns:
      a new media context
    • builder

      Builder to set up this encoding support context.
      Returns:
      a new builder
    • contentEncodingEnabled

      boolean contentEncodingEnabled()
      There is at least one content encoder.
      Returns:
      whether there is at least one content encoder
    • contentDecodingEnabled

      boolean contentDecodingEnabled()
      There is at least one content decoder.
      Returns:
      whether there is at least one content decoder
    • contentEncodingSupported

      boolean contentEncodingSupported(String encodingId)
      Whether there is a content encoder for the provided id.
      Parameters:
      encodingId - encoding id
      Returns:
      whether a provider exists for this id
    • contentEncodingIds

      default List<String> contentEncodingIds()
      Content encoding ids accepted by configured providers and applicable to response bodies, in server preference order. The implicit identity content coding is not included.
      Returns:
      available response content encoding provider ids
    • canonicalEncodingId

      default Optional<String> canonicalEncodingId(String encodingId)
      Resolve a content encoding id to the canonical id of its configured provider. Encoding ids handled by the same provider return the same canonical id. The implicit identity content coding resolves to identity even though it has no configured provider. The result is intended for comparing encoding ids, not for selecting the value of a Content-Encoding response header.
      Parameters:
      encodingId - encoding id
      Returns:
      canonical encoding id, or empty if there is no encoder for the id and the id is not identity
    • contentDecodingSupported

      boolean contentDecodingSupported(String encodingId)
      Whether there is a content decoder for the provided id.
      Parameters:
      encodingId - encoding id
      Returns:
      whether a provider exists for this id
    • encoder

      ContentEncoder encoder(String encodingId) throws NoSuchElementException
      Obtain a content encoder for the id.
      Parameters:
      encodingId - encoding id
      Returns:
      content encoder to use
      Throws:
      NoSuchElementException - in case an encoding provider does not exist
    • decoder

      ContentDecoder decoder(String encodingId) throws NoSuchElementException
      Obtain a content decoder for the id.
      Parameters:
      encodingId - encoding id
      Returns:
      content decoder to use
      Throws:
      NoSuchElementException - in case a decoding provider does not exist
    • encoder

      ContentEncoder encoder(Headers headers)
      Discover content encoder based on the HTTP headers.
      Parameters:
      headers - headers to analyze
      Returns:
      content encoder to use
      Throws:
      HttpException - with status 400 if Accept-Encoding is malformed, or status 406 if no response content encoding is acceptable