Class ContentDecoder

All Implemented Interfaces:
SessionFeature, Proxy

@Generated("org.javagi.JavaGI") public final class ContentDecoder extends GObject implements SessionFeature

Handles decoding of HTTP messages.

ContentDecoder handles adding the "Accept-Encoding" header on outgoing messages, and processing the "Content-Encoding" header on incoming ones. Currently it supports the "gzip", "deflate", and "br" content codings.

A ContentDecoder will automatically be added to the session by default. (You can use Session.removeFeatureByType(Type) if you don't want this.)

If ContentDecoder successfully decodes the Content-Encoding, the message body will contain the decoded data; however, the message headers will be unchanged (and so "Content-Encoding" will still be present, "Content-Length" will describe the original encoded length, etc).

If "Content-Encoding" contains any encoding types that ContentDecoder doesn't recognize, then none of the encodings will be decoded.

(Note that currently there is no way to (automatically) use Content-Encoding when sending a request body, or to pick specific encoding types to support.)

  • Constructor Details

    • ContentDecoder

      public ContentDecoder(MemorySegment address)
      Create a ContentDecoder instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • ContentDecoder

      public ContentDecoder()
      Create a new ContentDecoder.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the ContentDecoder class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected ContentDecoder asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • builder

      public static ContentDecoder.Builder<? extends ContentDecoder.Builder> builder()
      A ContentDecoder.Builder object constructs a ContentDecoder with the specified properties. Use the various set...() methods to set properties, and finish construction with ContentDecoder.Builder.build().
      Returns:
      the builder object