Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
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 [classmessage
] emits its signalmessage
[gotHeaders] signal.
ContentSniffer
implements [ifacesessionFeature
], so you can add
content sniffing to a session with [methodsession
.add_feature] or
[methodsession
.add_feature_by_type].
Synopsis
- newtype ContentSniffer = ContentSniffer (ManagedPtr ContentSniffer)
- class (GObject o, IsDescendantOf ContentSniffer o) => IsContentSniffer o
- toContentSniffer :: (MonadIO m, IsContentSniffer o) => o -> m ContentSniffer
- contentSnifferNew :: (HasCallStack, MonadIO m) => m ContentSniffer
- contentSnifferSniff :: (HasCallStack, MonadIO m, IsContentSniffer a, IsMessage b) => a -> b -> Bytes -> m (Text, Maybe (Map Text Text))
Exported types
newtype ContentSniffer Source #
Memory-managed wrapper type.
ContentSniffer (ManagedPtr ContentSniffer) |
Instances
Eq ContentSniffer Source # | |
Defined in GI.Soup.Objects.ContentSniffer (==) :: ContentSniffer -> ContentSniffer -> Bool # (/=) :: ContentSniffer -> ContentSniffer -> Bool # | |
GObject ContentSniffer Source # | |
Defined in GI.Soup.Objects.ContentSniffer | |
ManagedPtrNewtype ContentSniffer Source # | |
Defined in GI.Soup.Objects.ContentSniffer toManagedPtr :: ContentSniffer -> ManagedPtr ContentSniffer | |
TypedObject ContentSniffer Source # | |
Defined in GI.Soup.Objects.ContentSniffer | |
HasParentTypes ContentSniffer Source # | |
Defined in GI.Soup.Objects.ContentSniffer | |
IsGValue (Maybe ContentSniffer) Source # | Convert |
Defined in GI.Soup.Objects.ContentSniffer gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe ContentSniffer -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe ContentSniffer) | |
type ParentTypes ContentSniffer Source # | |
Defined in GI.Soup.Objects.ContentSniffer |
class (GObject o, IsDescendantOf ContentSniffer o) => IsContentSniffer o Source #
Type class for types which can be safely cast to ContentSniffer
, for instance with toContentSniffer
.
Instances
(GObject o, IsDescendantOf ContentSniffer o) => IsContentSniffer o Source # | |
Defined in GI.Soup.Objects.ContentSniffer |
toContentSniffer :: (MonadIO m, IsContentSniffer o) => o -> m ContentSniffer Source #
Cast to ContentSniffer
, for types for which this is known to be safe. For general casts, use castTo
.
Methods
Click to display all available methods, including inherited ones
Methods
bindProperty, bindPropertyFull, forceFloating, freezeNotify, getv, isFloating, notify, notifyByPspec, ref, refSink, runDispose, sniff, stealData, stealQdata, thawNotify, unref, watchClosure.
Getters
getData, getProperty, getQdata.
Setters
new
:: (HasCallStack, MonadIO m) | |
=> m ContentSniffer | Returns: a new |
Creates a new ContentSniffer
.
sniff
:: (HasCallStack, MonadIO m, IsContentSniffer a, IsMessage b) | |
=> a |
|
-> b |
|
-> Bytes |
|
-> m (Text, Maybe (Map Text Text)) | Returns: the sniffed Content-Type of |
Sniffs buffer
to determine its Content-Type.
The result may also be influenced by the Content-Type declared in msg
's
response headers.