Class ContentSniffer

All Implemented Interfaces:
SessionFeature, Proxy

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

Sniffs the mime type of messages.

A ContentSniffer tries to detect the actual content type of the files that are being downloaded by looking at some of the data before the Message emits its Message::got-headers signal. ContentSniffer implements SessionFeature, so you can add content sniffing to a session with Session.addFeature(SessionFeature) or Session.addFeatureByType(Type).

  • Constructor Details

    • ContentSniffer

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

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

    • getType

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

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

      protected ContentSniffer 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
    • sniff

      public String sniff(Message msg, byte[] buffer, @Nullable Out<HashTable<String,String>> params)

      Sniffs buffer to determine its Content-Type.

      The result may also be influenced by the Content-Type declared in msg's response headers.

      Parameters:
      msg - the message to sniff
      buffer - a buffer containing the start of msg's response body
      params - return location for Content-Type parameters (eg, "charset"), or null
      Returns:
      the sniffed Content-Type of buffer; this will never be null, but may be application/octet-stream.
    • builder

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