:right-sidebar: True ContentSniffer =================================================================== .. currentmodule:: gi.repository.Soup .. class:: ContentSniffer(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Implemented Interfaces: :class:`~gi.repository.Soup.SessionFeature` Sniffs the mime type of messages. A :obj:`~gi.repository.Soup.ContentSniffer` tries to detect the actual content type of the files that are being downloaded by looking at some of the data before the :obj:`~gi.repository.Soup.Message` emits its :obj:`~gi.repository.Soup.Message.signals.got_headers` signal. :obj:`~gi.repository.Soup.ContentSniffer` implements :obj:`~gi.repository.Soup.SessionFeature`\, so you can add content sniffing to a session with :obj:`~gi.repository.Session.add_feature` or :obj:`~gi.repository.Session.add_feature_by_type`\. Constructors ------------ .. rst-class:: interim-class .. class:: ContentSniffer :no-index: .. classmethod:: new() -> ~gi.repository.Soup.ContentSniffer Creates a new :obj:`~gi.repository.Soup.ContentSniffer`\. Methods ------- .. rst-class:: interim-class .. class:: ContentSniffer :no-index: .. method:: sniff(msg: ~gi.repository.Soup.Message, buffer: ~gi.repository.GLib.Bytes) -> ~typing.Tuple[str, dict[str, str] | None] Sniffs ``buffer`` to determine its Content-Type. The result may also be influenced by the Content-Type declared in ``msg``\'s response headers. :param msg: the message to sniff :param buffer: a buffer containing the start of ``msg``\'s response body