Soup.ContentSniffer¶
- Subclasses:
None
Methods¶
- Inherited:
- Structs:
class |
|
|
Virtual Methods¶
- Inherited:
Properties¶
None
Signals¶
- Inherited:
Fields¶
- Inherited:
Class Details¶
- class Soup.ContentSniffer(**kwargs)¶
- Bases:
- Abstract:
No
- Structure:
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:
Creates a new
Soup.ContentSniffer
.
- sniff(msg, buffer)¶
- Parameters:
msg (
Soup.Message
) – the message to sniffbuffer (
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 beapplication/octet-stream
.- params:
return location for Content-Type parameters (eg, “charset”), or
None
- Return type:
Sniffs buffer to determine its Content-Type.
The result may also be influenced by the Content-Type declared in msg's response headers.