gi-soup-2.4.24: Libsoup bindings
CopyrightWill Thompson Iñaki García Etxebarria and Jonas Platte
LicenseLGPL-2.1
MaintainerIñaki García Etxebarria
Safe HaskellSafe-Inferred
LanguageHaskell2010

GI.Soup.Objects.ContentSniffer

Description

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 gotHeaders signal. ContentSniffer implements SessionFeature, so you can add content sniffing to a session with sessionAddFeature or sessionAddFeatureByType.

Since: 2.28

Synopsis

Exported types

newtype ContentSniffer Source #

Memory-managed wrapper type.

Constructors

ContentSniffer (ManagedPtr ContentSniffer) 

Instances

Instances details
Eq ContentSniffer Source # 
Instance details

Defined in GI.Soup.Objects.ContentSniffer

GObject ContentSniffer Source # 
Instance details

Defined in GI.Soup.Objects.ContentSniffer

ManagedPtrNewtype ContentSniffer Source # 
Instance details

Defined in GI.Soup.Objects.ContentSniffer

TypedObject ContentSniffer Source # 
Instance details

Defined in GI.Soup.Objects.ContentSniffer

Methods

glibType :: IO GType

HasParentTypes ContentSniffer Source # 
Instance details

Defined in GI.Soup.Objects.ContentSniffer

IsGValue (Maybe ContentSniffer) Source #

Convert ContentSniffer to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Soup.Objects.ContentSniffer

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe ContentSniffer -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe ContentSniffer)

type ParentTypes ContentSniffer Source # 
Instance details

Defined in GI.Soup.Objects.ContentSniffer

type ParentTypes ContentSniffer = '[Object, SessionFeature]

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

Instances details
(GObject o, IsDescendantOf ContentSniffer o) => IsContentSniffer o Source # 
Instance details

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

getBufferSize

contentSnifferGetBufferSize Source #

Arguments

:: (HasCallStack, MonadIO m, IsContentSniffer a) 
=> a

sniffer: a ContentSniffer

-> m Word64

Returns: the number of bytes to sniff

Gets the number of bytes sniffer needs in order to properly sniff a buffer.

Since: 2.28

new

contentSnifferNew Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> m ContentSniffer

Returns: a new ContentSniffer

Creates a new ContentSniffer.

Since: 2.28

sniff

contentSnifferSniff Source #

Arguments

:: (HasCallStack, MonadIO m, IsContentSniffer a, IsMessage b) 
=> a

sniffer: a ContentSniffer

-> b

msg: the message to sniff

-> Buffer

buffer: a buffer containing the start of msg's response body

-> m (Text, Map Text Text)

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

Sniffs buffer to determine its Content-Type. The result may also be influenced by the Content-Type declared in msg's response headers.

Since: 2.28