Soup.ContentSniffer

g GObject.GInterface GObject.GInterface Soup.SessionFeature Soup.SessionFeature GObject.GInterface->Soup.SessionFeature GObject.Object GObject.Object Soup.ContentSniffer Soup.ContentSniffer GObject.Object->Soup.ContentSniffer Soup.SessionFeature->Soup.ContentSniffer

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

new ()

sniff (msg, buffer)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

None

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class Soup.ContentSniffer(**kwargs)
Bases:

GObject.Object, Soup.SessionFeature

Abstract:

No

Structure:

Soup.ContentSnifferClass

Sniffs the mime type of messages.

A 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 [class`Message`] emits its [signal`Message`:py:func:::got-headers<Soup.ContentSniffer.signals.got_headers>] signal. Soup.ContentSniffer implements [iface`SessionFeature`], so you can add content sniffing to a session with [method`Session`.add_feature] or [method`Session`.add_feature_by_type].

classmethod new()
Returns:

a new Soup.ContentSniffer

Return type:

Soup.ContentSniffer

Creates a new Soup.ContentSniffer.

sniff(msg, buffer)
Parameters:
  • msg (Soup.Message) – the message to sniff

  • buffer (GLib.Bytes) – a buffer containing the start of msg's response body

Returns:

the sniffed Content-Type of buffer; this will never be None, but may be application/octet-stream.

params:

return location for Content-Type parameters (eg, “charset”), or None

Return type:

(str, params: {str: str})

Sniffs buffer to determine its Content-Type.

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