-- | Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
-- License    : LGPL-2.1
-- Maintainer : Iñaki García Etxebarria

#if (MIN_VERSION_haskell_gi_overloading(1,0,0) && !defined(__HADDOCK_VERSION__))
#define ENABLE_OVERLOADING
#endif

module GI.Soup.Functions
    ( 

 -- * Methods
-- ** checkVersion #method:checkVersion#

    checkVersion                            ,


-- ** cookiesFromRequest #method:cookiesFromRequest#

    cookiesFromRequest                      ,


-- ** cookiesFromResponse #method:cookiesFromResponse#

    cookiesFromResponse                     ,


-- ** cookiesToCookieHeader #method:cookiesToCookieHeader#

    cookiesToCookieHeader                   ,


-- ** cookiesToRequest #method:cookiesToRequest#

    cookiesToRequest                        ,


-- ** cookiesToResponse #method:cookiesToResponse#

    cookiesToResponse                       ,


-- ** formEncodeDatalist #method:formEncodeDatalist#

    formEncodeDatalist                      ,


-- ** formEncodeHash #method:formEncodeHash#

    formEncodeHash                          ,


-- ** formRequestNewFromDatalist #method:formRequestNewFromDatalist#

    formRequestNewFromDatalist              ,


-- ** formRequestNewFromHash #method:formRequestNewFromHash#

    formRequestNewFromHash                  ,


-- ** formRequestNewFromMultipart #method:formRequestNewFromMultipart#

    formRequestNewFromMultipart             ,


-- ** getMajorVersion #method:getMajorVersion#

    getMajorVersion                         ,


-- ** getMicroVersion #method:getMicroVersion#

    getMicroVersion                         ,


-- ** getMinorVersion #method:getMinorVersion#

    getMinorVersion                         ,


-- ** headerContains #method:headerContains#

    headerContains                          ,


-- ** headerFreeParamList #method:headerFreeParamList#

    headerFreeParamList                     ,


-- ** headerGStringAppendParam #method:headerGStringAppendParam#

    headerGStringAppendParam                ,


-- ** headerGStringAppendParamQuoted #method:headerGStringAppendParamQuoted#

    headerGStringAppendParamQuoted          ,


-- ** headerParseList #method:headerParseList#

    headerParseList                         ,


-- ** headerParseParamList #method:headerParseParamList#

    headerParseParamList                    ,


-- ** headerParseParamListStrict #method:headerParseParamListStrict#

    headerParseParamListStrict              ,


-- ** headerParseQualityList #method:headerParseQualityList#

    headerParseQualityList                  ,


-- ** headerParseSemiParamList #method:headerParseSemiParamList#

    headerParseSemiParamList                ,


-- ** headerParseSemiParamListStrict #method:headerParseSemiParamListStrict#

    headerParseSemiParamListStrict          ,


-- ** headersParse #method:headersParse#

    headersParse                            ,


-- ** headersParseRequest #method:headersParseRequest#

    headersParseRequest                     ,


-- ** headersParseResponse #method:headersParseResponse#

    headersParseResponse                    ,


-- ** headersParseStatusLine #method:headersParseStatusLine#

    headersParseStatusLine                  ,


-- ** httpErrorQuark #method:httpErrorQuark#

    httpErrorQuark                          ,


-- ** strCaseEqual #method:strCaseEqual#

    strCaseEqual                            ,


-- ** strCaseHash #method:strCaseHash#

    strCaseHash                             ,


-- ** tldDomainIsPublicSuffix #method:tldDomainIsPublicSuffix#

    tldDomainIsPublicSuffix                 ,


-- ** tldGetBaseDomain #method:tldGetBaseDomain#

    tldGetBaseDomain                        ,


-- ** valueArrayNew #method:valueArrayNew#

    valueArrayNew                           ,


-- ** websocketClientPrepareHandshake #method:websocketClientPrepareHandshake#

    websocketClientPrepareHandshake         ,


-- ** websocketClientPrepareHandshakeWithExtensions #method:websocketClientPrepareHandshakeWithExtensions#

    websocketClientPrepareHandshakeWithExtensions,


-- ** websocketClientVerifyHandshake #method:websocketClientVerifyHandshake#

    websocketClientVerifyHandshake          ,


-- ** websocketClientVerifyHandshakeWithExtensions #method:websocketClientVerifyHandshakeWithExtensions#

    websocketClientVerifyHandshakeWithExtensions,


-- ** websocketServerCheckHandshake #method:websocketServerCheckHandshake#

    websocketServerCheckHandshake           ,


-- ** websocketServerCheckHandshakeWithExtensions #method:websocketServerCheckHandshakeWithExtensions#

    websocketServerCheckHandshakeWithExtensions,


-- ** websocketServerProcessHandshake #method:websocketServerProcessHandshake#

    websocketServerProcessHandshake         ,


-- ** websocketServerProcessHandshakeWithExtensions #method:websocketServerProcessHandshakeWithExtensions#

    websocketServerProcessHandshakeWithExtensions,


-- ** xmlrpcBuildMethodCall #method:xmlrpcBuildMethodCall#

    xmlrpcBuildMethodCall                   ,


-- ** xmlrpcBuildMethodResponse #method:xmlrpcBuildMethodResponse#

    xmlrpcBuildMethodResponse               ,


-- ** xmlrpcBuildRequest #method:xmlrpcBuildRequest#

    xmlrpcBuildRequest                      ,


-- ** xmlrpcBuildResponse #method:xmlrpcBuildResponse#

    xmlrpcBuildResponse                     ,


-- ** xmlrpcMessageNew #method:xmlrpcMessageNew#

    xmlrpcMessageNew                        ,


-- ** xmlrpcMessageSetResponse #method:xmlrpcMessageSetResponse#

    xmlrpcMessageSetResponse                ,


-- ** xmlrpcParseMethodCall #method:xmlrpcParseMethodCall#

    xmlrpcParseMethodCall                   ,


-- ** xmlrpcParseMethodResponse #method:xmlrpcParseMethodResponse#

    xmlrpcParseMethodResponse               ,


-- ** xmlrpcParseRequest #method:xmlrpcParseRequest#

    xmlrpcParseRequest                      ,


-- ** xmlrpcParseResponse #method:xmlrpcParseResponse#

    xmlrpcParseResponse                     ,


-- ** xmlrpcVariantGetDatetime #method:xmlrpcVariantGetDatetime#

    xmlrpcVariantGetDatetime                ,


-- ** xmlrpcVariantNewDatetime #method:xmlrpcVariantNewDatetime#

    xmlrpcVariantNewDatetime                ,




    ) where

import Data.GI.Base.ShortPrelude
import qualified Data.GI.Base.ShortPrelude as SP
import qualified Data.GI.Base.Overloading as O
import qualified Prelude as P

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.BasicTypes as B.Types
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.GI.Base.Signals as B.Signals
import qualified Control.Monad.IO.Class as MIO
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GLib.Structs.Data as GLib.Data
import qualified GI.GLib.Structs.String as GLib.String
import qualified GI.GObject.Structs.TypeClass as GObject.TypeClass
import qualified GI.GObject.Structs.ValueArray as GObject.ValueArray
import {-# SOURCE #-} qualified GI.Soup.Enums as Soup.Enums
import {-# SOURCE #-} qualified GI.Soup.Objects.Message as Soup.Message
import {-# SOURCE #-} qualified GI.Soup.Objects.WebsocketExtension as Soup.WebsocketExtension
import {-# SOURCE #-} qualified GI.Soup.Structs.Cookie as Soup.Cookie
import {-# SOURCE #-} qualified GI.Soup.Structs.Date as Soup.Date
import {-# SOURCE #-} qualified GI.Soup.Structs.MessageHeaders as Soup.MessageHeaders
import {-# SOURCE #-} qualified GI.Soup.Structs.Multipart as Soup.Multipart
import {-# SOURCE #-} qualified GI.Soup.Structs.XMLRPCParams as Soup.XMLRPCParams

-- function xmlrpc_variant_new_datetime
-- Args: [ Arg
--           { argCName = "date"
--           , argType = TInterface Name { namespace = "Soup" , name = "Date" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupDate" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_variant_new_datetime" soup_xmlrpc_variant_new_datetime :: 
    Ptr Soup.Date.Date ->                   -- date : TInterface (Name {namespace = "Soup", name = "Date"})
    IO (Ptr GVariant)

-- | Construct a special t'GVariant' used to serialize a <dateTime.iso8601>
-- node. See 'GI.Soup.Functions.xmlrpcBuildRequest'.
-- 
-- The actual type of the returned t'GVariant' is unspecified and \"v\" or \"*\"
-- should be used in variant format strings. For example:
-- \<informalexample>\<programlisting>
-- args = g_variant_new (\"(v)\", soup_xmlrpc_variant_new_datetime (date));
-- \<\/programlisting>\<\/informalexample>
-- 
-- /Since: 2.52/
xmlrpcVariantNewDatetime ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Soup.Date.Date
    -- ^ /@date@/: a t'GI.Soup.Structs.Date.Date'
    -> m GVariant
    -- ^ __Returns:__ a floating t'GVariant'.
xmlrpcVariantNewDatetime :: Date -> m GVariant
xmlrpcVariantNewDatetime Date
date = IO GVariant -> m GVariant
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    Ptr Date
date' <- Date -> IO (Ptr Date)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Date
date
    Ptr GVariant
result <- Ptr Date -> IO (Ptr GVariant)
soup_xmlrpc_variant_new_datetime Ptr Date
date'
    Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"xmlrpcVariantNewDatetime" Ptr GVariant
result
    GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.wrapGVariantPtr Ptr GVariant
result
    Date -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Date
date
    GVariant -> IO GVariant
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'


-- function xmlrpc_variant_get_datetime
-- Args: [ Arg
--           { argCName = "variant"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "Date" })
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_variant_get_datetime" soup_xmlrpc_variant_get_datetime :: 
    Ptr GVariant ->                         -- variant : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Soup.Date.Date)

-- | Get the t'GI.Soup.Structs.Date.Date' from special t'GVariant' created by
-- 'GI.Soup.Functions.xmlrpcVariantNewDatetime' or by parsing a &lt;dateTime.iso8601&gt;
-- node. See 'GI.Soup.Structs.XMLRPCParams.xMLRPCParamsParse'.
-- 
-- If /@variant@/ does not contain a datetime it will return an error but it is not
-- considered a programmer error because it generally means parameters received
-- are not in the expected type.
-- 
-- /Since: 2.52/
xmlrpcVariantGetDatetime ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@variant@/: a t'GVariant'
    -> m Soup.Date.Date
    -- ^ __Returns:__ a new t'GI.Soup.Structs.Date.Date', or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcVariantGetDatetime :: GVariant -> m Date
xmlrpcVariantGetDatetime GVariant
variant = IO Date -> m Date
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Date -> m Date) -> IO Date -> m Date
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
variant' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
variant
    IO Date -> IO () -> IO Date
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Date
result <- (Ptr (Ptr GError) -> IO (Ptr Date)) -> IO (Ptr Date)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Date)) -> IO (Ptr Date))
-> (Ptr (Ptr GError) -> IO (Ptr Date)) -> IO (Ptr Date)
forall a b. (a -> b) -> a -> b
$ Ptr GVariant -> Ptr (Ptr GError) -> IO (Ptr Date)
soup_xmlrpc_variant_get_datetime Ptr GVariant
variant'
        Text -> Ptr Date -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"xmlrpcVariantGetDatetime" Ptr Date
result
        Date
result' <- ((ManagedPtr Date -> Date) -> Ptr Date -> IO Date
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Date -> Date
Soup.Date.Date) Ptr Date
result
        GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
variant
        Date -> IO Date
forall (m :: * -> *) a. Monad m => a -> m a
return Date
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function xmlrpc_parse_response
-- Args: [ Arg
--           { argCName = "method_response"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the XML-RPC methodResponse string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @method_response, or -1 if it is NUL-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "signature"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "A valid #GVariant type string, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just TVariant
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_parse_response" soup_xmlrpc_parse_response :: 
    CString ->                              -- method_response : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    CString ->                              -- signature : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GVariant)

-- | Parses /@methodResponse@/ and returns the return value. If
-- /@methodResponse@/ is a fault, 'P.Nothing' is returned, and /@error@/
-- will be set to an error in the @/SOUP_XMLRPC_FAULT/@ domain, with the error
-- code containing the fault code, and the error message containing
-- the fault string. If /@methodResponse@/ cannot be parsed, 'P.Nothing' is returned,
-- and /@error@/ will be set to an error in the @/SOUP_XMLRPC_ERROR/@ domain.
-- 
-- See 'GI.Soup.Structs.XMLRPCParams.xMLRPCParamsParse' for deserialization details.
-- 
-- /Since: 2.52/
xmlrpcParseResponse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@methodResponse@/: the XML-RPC methodResponse string
    -> Int32
    -- ^ /@length@/: the length of /@methodResponse@/, or -1 if it is NUL-terminated
    -> Maybe (T.Text)
    -- ^ /@signature@/: A valid t'GVariant' type string, or 'P.Nothing'
    -> m GVariant
    -- ^ __Returns:__ a new (non-floating) t'GVariant', or 'P.Nothing' /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcParseResponse :: Text -> Int32 -> Maybe Text -> m GVariant
xmlrpcParseResponse Text
methodResponse Int32
length_ Maybe Text
signature = IO GVariant -> m GVariant
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GVariant -> m GVariant) -> IO GVariant -> m GVariant
forall a b. (a -> b) -> a -> b
$ do
    CString
methodResponse' <- Text -> IO CString
textToCString Text
methodResponse
    CString
maybeSignature <- case Maybe Text
signature of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jSignature -> do
            CString
jSignature' <- Text -> IO CString
textToCString Text
jSignature
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jSignature'
    IO GVariant -> IO () -> IO GVariant
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr GVariant
result <- (Ptr (Ptr GError) -> IO (Ptr GVariant)) -> IO (Ptr GVariant)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr GVariant)) -> IO (Ptr GVariant))
-> (Ptr (Ptr GError) -> IO (Ptr GVariant)) -> IO (Ptr GVariant)
forall a b. (a -> b) -> a -> b
$ CString
-> Int32 -> CString -> Ptr (Ptr GError) -> IO (Ptr GVariant)
soup_xmlrpc_parse_response CString
methodResponse' Int32
length_ CString
maybeSignature
        Text -> Ptr GVariant -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"xmlrpcParseResponse" Ptr GVariant
result
        GVariant
result' <- Ptr GVariant -> IO GVariant
B.GVariant.wrapGVariantPtr Ptr GVariant
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodResponse'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeSignature
        GVariant -> IO GVariant
forall (m :: * -> *) a. Monad m => a -> m a
return GVariant
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodResponse'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeSignature
     )


-- function xmlrpc_parse_request
-- Args: [ Arg
--           { argCName = "method_call"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the XML-RPC methodCall string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the length of @method_call, or -1 if it is NUL-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "params"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "XMLRPCParams" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "on success, a new #SoupXMLRPCParams"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_parse_request" soup_xmlrpc_parse_request :: 
    CString ->                              -- method_call : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Ptr (Ptr Soup.XMLRPCParams.XMLRPCParams) -> -- params : TInterface (Name {namespace = "Soup", name = "XMLRPCParams"})
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Parses /@methodCall@/ and return the method name. Method parameters can be
-- parsed later using 'GI.Soup.Structs.XMLRPCParams.xMLRPCParamsParse'.
-- 
-- /Since: 2.52/
xmlrpcParseRequest ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@methodCall@/: the XML-RPC methodCall string
    -> Int32
    -- ^ /@length@/: the length of /@methodCall@/, or -1 if it is NUL-terminated
    -> m ((T.Text, Soup.XMLRPCParams.XMLRPCParams))
    -- ^ __Returns:__ method\'s name, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcParseRequest :: Text -> Int32 -> m (Text, XMLRPCParams)
xmlrpcParseRequest Text
methodCall Int32
length_ = IO (Text, XMLRPCParams) -> m (Text, XMLRPCParams)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Text, XMLRPCParams) -> m (Text, XMLRPCParams))
-> IO (Text, XMLRPCParams) -> m (Text, XMLRPCParams)
forall a b. (a -> b) -> a -> b
$ do
    CString
methodCall' <- Text -> IO CString
textToCString Text
methodCall
    Ptr (Ptr XMLRPCParams)
params <- IO (Ptr (Ptr XMLRPCParams))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr Soup.XMLRPCParams.XMLRPCParams))
    IO (Text, XMLRPCParams) -> IO () -> IO (Text, XMLRPCParams)
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString
-> Int32
-> Ptr (Ptr XMLRPCParams)
-> Ptr (Ptr GError)
-> IO CString
soup_xmlrpc_parse_request CString
methodCall' Int32
length_ Ptr (Ptr XMLRPCParams)
params
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"xmlrpcParseRequest" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        Ptr XMLRPCParams
params' <- Ptr (Ptr XMLRPCParams) -> IO (Ptr XMLRPCParams)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr XMLRPCParams)
params
        XMLRPCParams
params'' <- ((ManagedPtr XMLRPCParams -> XMLRPCParams)
-> Ptr XMLRPCParams -> IO XMLRPCParams
forall a.
(HasCallStack, BoxedPtr a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapPtr ManagedPtr XMLRPCParams -> XMLRPCParams
Soup.XMLRPCParams.XMLRPCParams) Ptr XMLRPCParams
params'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodCall'
        Ptr (Ptr XMLRPCParams) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr XMLRPCParams)
params
        (Text, XMLRPCParams) -> IO (Text, XMLRPCParams)
forall (m :: * -> *) a. Monad m => a -> m a
return (Text
result', XMLRPCParams
params'')
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodCall'
        Ptr (Ptr XMLRPCParams) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr XMLRPCParams)
params
     )


-- function xmlrpc_parse_method_response
-- Args: [ Arg
--           { argCName = "method_response"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the XML-RPC methodResponse string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the length of @method_response, or -1 if it is NUL-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TGValue
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "on return, the return value from @method_call"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = True
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_parse_method_response" soup_xmlrpc_parse_method_response :: 
    CString ->                              -- method_response : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Ptr GValue ->                           -- value : TGValue
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED xmlrpcParseMethodResponse ["Use 'GI.Soup.Functions.xmlrpcParseResponse' instead."] #-}
-- | Parses /@methodResponse@/ and returns the return value in /@value@/. If
-- /@methodResponse@/ is a fault, /@value@/ will be unchanged, and /@error@/
-- will be set to an error of type @/SOUP_XMLRPC_FAULT/@, with the error
-- @/code/@ containing the fault code, and the error @/message/@ containing
-- the fault string. (If /@methodResponse@/ cannot be parsed at all,
-- 'GI.Soup.Functions.xmlrpcParseMethodResponse' will return 'P.False', but /@error@/
-- will be unset.)
xmlrpcParseMethodResponse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@methodResponse@/: the XML-RPC methodResponse string
    -> Int32
    -- ^ /@length@/: the length of /@methodResponse@/, or -1 if it is NUL-terminated
    -> m (GValue)
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcParseMethodResponse :: Text -> Int32 -> m GValue
xmlrpcParseMethodResponse Text
methodResponse Int32
length_ = IO GValue -> m GValue
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO GValue -> m GValue) -> IO GValue -> m GValue
forall a b. (a -> b) -> a -> b
$ do
    CString
methodResponse' <- Text -> IO CString
textToCString Text
methodResponse
    Ptr GValue
value <- Int -> IO (Ptr GValue)
forall a. Int -> IO (Ptr a)
SP.callocBytes Int
24 :: IO (Ptr GValue)
    IO GValue -> IO () -> IO GValue
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ CString -> Int32 -> Ptr GValue -> Ptr (Ptr GError) -> IO CInt
soup_xmlrpc_parse_method_response CString
methodResponse' Int32
length_ Ptr GValue
value
        GValue
value' <- Ptr GValue -> IO GValue
B.GValue.wrapGValuePtr Ptr GValue
value
        Ptr GValue -> IO ()
B.GValue.unsetGValue Ptr GValue
value
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodResponse'
        GValue -> IO GValue
forall (m :: * -> *) a. Monad m => a -> m a
return GValue
value'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodResponse'
        Ptr GValue -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr GValue
value
     )


-- function xmlrpc_parse_method_call
-- Args: [ Arg
--           { argCName = "method_call"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the XML-RPC methodCall string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "length"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the length of @method_call, or -1 if it is NUL-terminated"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "method_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "on return, the methodName from @method_call"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "params"
--           , argType =
--               TInterface Name { namespace = "GObject" , name = "ValueArray" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "on return, the parameters from @method_call"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_parse_method_call" soup_xmlrpc_parse_method_call :: 
    CString ->                              -- method_call : TBasicType TUTF8
    Int32 ->                                -- length : TBasicType TInt
    Ptr CString ->                          -- method_name : TBasicType TUTF8
    Ptr (Ptr GObject.ValueArray.ValueArray) -> -- params : TInterface (Name {namespace = "GObject", name = "ValueArray"})
    IO CInt

{-# DEPRECATED xmlrpcParseMethodCall ["Use @/soup_xmlrpc_parse_request_full()/@ instead."] #-}
-- | Parses /@methodCall@/ to get the name and parameters, and returns the
-- parameter values in a t'GI.GObject.Structs.ValueArray.ValueArray'; see also
-- @/soup_xmlrpc_extract_method_call()/@, which is more convenient if you
-- know in advance what the types of the parameters will be.
xmlrpcParseMethodCall ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@methodCall@/: the XML-RPC methodCall string
    -> Int32
    -- ^ /@length@/: the length of /@methodCall@/, or -1 if it is NUL-terminated
    -> m ((Bool, T.Text, GObject.ValueArray.ValueArray))
    -- ^ __Returns:__ success or failure.
xmlrpcParseMethodCall :: Text -> Int32 -> m (Bool, Text, ValueArray)
xmlrpcParseMethodCall Text
methodCall Int32
length_ = IO (Bool, Text, ValueArray) -> m (Bool, Text, ValueArray)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, Text, ValueArray) -> m (Bool, Text, ValueArray))
-> IO (Bool, Text, ValueArray) -> m (Bool, Text, ValueArray)
forall a b. (a -> b) -> a -> b
$ do
    CString
methodCall' <- Text -> IO CString
textToCString Text
methodCall
    Ptr CString
methodName <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    Ptr (Ptr ValueArray)
params <- IO (Ptr (Ptr ValueArray))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr GObject.ValueArray.ValueArray))
    CInt
result <- CString -> Int32 -> Ptr CString -> Ptr (Ptr ValueArray) -> IO CInt
soup_xmlrpc_parse_method_call CString
methodCall' Int32
length_ Ptr CString
methodName Ptr (Ptr ValueArray)
params
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString
methodName' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
methodName
    Text
methodName'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
methodName'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodName'
    Ptr ValueArray
params' <- Ptr (Ptr ValueArray) -> IO (Ptr ValueArray)
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr ValueArray)
params
    ValueArray
params'' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr ValueArray -> ValueArray
GObject.ValueArray.ValueArray) Ptr ValueArray
params'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodCall'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
methodName
    Ptr (Ptr ValueArray) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr ValueArray)
params
    (Bool, Text, ValueArray) -> IO (Bool, Text, ValueArray)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', Text
methodName'', ValueArray
params'')


-- function xmlrpc_message_set_response
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an XML-RPC request" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_message_set_response" soup_xmlrpc_message_set_response :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    Ptr GVariant ->                         -- value : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Sets the status code and response body of /@msg@/ to indicate a
-- successful XML-RPC call, with a return value given by /@value@/. To set a
-- fault response, use @/soup_xmlrpc_message_set_fault()/@.
-- 
-- See 'GI.Soup.Functions.xmlrpcBuildRequest' for serialization details.
-- 
-- If /@value@/ is floating, it is consumed.
-- 
-- /Since: 2.52/
xmlrpcMessageSetResponse ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: an XML-RPC request
    -> GVariant
    -- ^ /@value@/: a t'GVariant'
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcMessageSetResponse :: a -> GVariant -> m ()
xmlrpcMessageSetResponse a
msg GVariant
value = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Message -> Ptr GVariant -> Ptr (Ptr GError) -> IO CInt
soup_xmlrpc_message_set_response Ptr Message
msg' Ptr GVariant
value'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
        GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function xmlrpc_message_new
-- Args: [ Arg
--           { argCName = "uri"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "URI of the XML-RPC service"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "method_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "the name of the XML-RPC method to invoke at @uri"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "params"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant tuple" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "Message" })
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_message_new" soup_xmlrpc_message_new :: 
    CString ->                              -- uri : TBasicType TUTF8
    CString ->                              -- method_name : TBasicType TUTF8
    Ptr GVariant ->                         -- params : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr Soup.Message.Message)

-- | Creates an XML-RPC methodCall and returns a t'GI.Soup.Objects.Message.Message', ready
-- to send, for that method call.
-- 
-- See 'GI.Soup.Functions.xmlrpcBuildRequest' for serialization details.
-- 
-- If /@params@/ is floating, it is consumed.
-- 
-- /Since: 2.52/
xmlrpcMessageNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@uri@/: URI of the XML-RPC service
    -> T.Text
    -- ^ /@methodName@/: the name of the XML-RPC method to invoke at /@uri@/
    -> GVariant
    -- ^ /@params@/: a t'GVariant' tuple
    -> m Soup.Message.Message
    -- ^ __Returns:__ a t'GI.Soup.Objects.Message.Message' encoding the
    --   indicated XML-RPC request, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcMessageNew :: Text -> Text -> GVariant -> m Message
xmlrpcMessageNew Text
uri Text
methodName GVariant
params = IO Message -> m Message
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Message -> m Message) -> IO Message -> m Message
forall a b. (a -> b) -> a -> b
$ do
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    CString
methodName' <- Text -> IO CString
textToCString Text
methodName
    Ptr GVariant
params' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
params
    IO Message -> IO () -> IO Message
forall a b. IO a -> IO b -> IO a
onException (do
        Ptr Message
result <- (Ptr (Ptr GError) -> IO (Ptr Message)) -> IO (Ptr Message)
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO (Ptr Message)) -> IO (Ptr Message))
-> (Ptr (Ptr GError) -> IO (Ptr Message)) -> IO (Ptr Message)
forall a b. (a -> b) -> a -> b
$ CString
-> CString -> Ptr GVariant -> Ptr (Ptr GError) -> IO (Ptr Message)
soup_xmlrpc_message_new CString
uri' CString
methodName' Ptr GVariant
params'
        Text -> Ptr Message -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"xmlrpcMessageNew" Ptr Message
result
        Message
result' <- ((ManagedPtr Message -> Message) -> Ptr Message -> IO Message
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Message -> Message
Soup.Message.Message) Ptr Message
result
        GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
params
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodName'
        Message -> IO Message
forall (m :: * -> *) a. Monad m => a -> m a
return Message
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodName'
     )


-- function xmlrpc_build_response
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the return value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_build_response" soup_xmlrpc_build_response :: 
    Ptr GVariant ->                         -- value : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | This creates a (successful) XML-RPC methodResponse and returns it
-- as a string. To create a fault response, use @/soup_xmlrpc_build_fault()/@. This
-- is the low-level method that 'GI.Soup.Functions.xmlrpcMessageSetResponse' is built on.
-- 
-- See 'GI.Soup.Functions.xmlrpcBuildRequest' for serialization details, but note
-- that since a method can only have a single return value, /@value@/
-- should not be a tuple here (unless the return value is an array).
-- 
-- If /@value@/ is floating, it is consumed.
-- 
-- /Since: 2.52/
xmlrpcBuildResponse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GVariant
    -- ^ /@value@/: the return value
    -> m T.Text
    -- ^ __Returns:__ the text of the methodResponse, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcBuildResponse :: GVariant -> m Text
xmlrpcBuildResponse GVariant
value = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr GVariant
value' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
value
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ Ptr GVariant -> Ptr (Ptr GError) -> IO CString
soup_xmlrpc_build_response Ptr GVariant
value'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"xmlrpcBuildResponse" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
value
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function xmlrpc_build_request
-- Args: [ Arg
--           { argCName = "method_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the XML-RPC method"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "params"
--           , argType = TVariant
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GVariant tuple" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_build_request" soup_xmlrpc_build_request :: 
    CString ->                              -- method_name : TBasicType TUTF8
    Ptr GVariant ->                         -- params : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | This creates an XML-RPC methodCall and returns it as a string.
-- This is the low-level method that 'GI.Soup.Functions.xmlrpcMessageNew' is
-- built on.
-- 
-- /@params@/ is a t'GVariant' tuple representing the method parameters.
-- 
-- Serialization details:
--  - \"a{s*}\" and \"{s*}\" are serialized as &lt;struct&gt;
--  - \"ay\" is serialized as &lt;base64&gt;
--  - Other arrays and tuples are serialized as &lt;array&gt;
--  - booleans are serialized as &lt;boolean&gt;
--  - byte, int16, uint16 and int32 are serialized as &lt;int&gt;
--  - uint32 and int64 are serialized as the nonstandard &lt;i8&gt; type
--  - doubles are serialized as &lt;double&gt;
--  - Strings are serialized as &lt;string&gt;
--  - Variants (i.e. \"v\" type) are unwrapped and their child is serialized.
--  - @/GVariants/@ created by 'GI.Soup.Functions.xmlrpcVariantNewDatetime' are serialized as
--    &lt;dateTime.iso8601&gt;
--  - Other types are not supported and will return 'P.Nothing' and set /@error@/.
--    This notably includes: object-paths, signatures, uint64, handles, maybes
--    and dictionaries with non-string keys.
-- 
-- If /@params@/ is floating, it is consumed.
-- 
-- /Since: 2.52/
xmlrpcBuildRequest ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@methodName@/: the name of the XML-RPC method
    -> GVariant
    -- ^ /@params@/: a t'GVariant' tuple
    -> m T.Text
    -- ^ __Returns:__ the text of the methodCall, or 'P.Nothing' on error. /(Can throw 'Data.GI.Base.GError.GError')/
xmlrpcBuildRequest :: Text -> GVariant -> m Text
xmlrpcBuildRequest Text
methodName GVariant
params = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
methodName' <- Text -> IO CString
textToCString Text
methodName
    Ptr GVariant
params' <- GVariant -> IO (Ptr GVariant)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GVariant
params
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString -> Ptr GVariant -> Ptr (Ptr GError) -> IO CString
soup_xmlrpc_build_request CString
methodName' Ptr GVariant
params'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"xmlrpcBuildRequest" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
        GVariant -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GVariant
params
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodName'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodName'
     )


-- function xmlrpc_build_method_response
-- Args: [ Arg
--           { argCName = "value"
--           , argType = TGValue
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the return value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_build_method_response" soup_xmlrpc_build_method_response :: 
    Ptr GValue ->                           -- value : TGValue
    IO CString

{-# DEPRECATED xmlrpcBuildMethodResponse ["Use 'GI.Soup.Functions.xmlrpcBuildResponse' instead."] #-}
-- | This creates a (successful) XML-RPC methodResponse and returns it
-- as a string. To create a fault response, use
-- @/soup_xmlrpc_build_fault()/@.
-- 
-- The glib type to XML-RPC type mapping is as with
-- 'GI.Soup.Functions.xmlrpcBuildMethodCall', qv.
xmlrpcBuildMethodResponse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GValue
    -- ^ /@value@/: the return value
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the text of the methodResponse, or 'P.Nothing'
    -- on error
xmlrpcBuildMethodResponse :: GValue -> m (Maybe Text)
xmlrpcBuildMethodResponse GValue
value = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    Ptr GValue
value' <- GValue -> IO (Ptr GValue)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr GValue
value
    CString
result <- Ptr GValue -> IO CString
soup_xmlrpc_build_method_response Ptr GValue
value'
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    GValue -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr GValue
value
    Ptr GValue -> IO ()
B.GValue.unsetGValue Ptr GValue
value'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- function xmlrpc_build_method_call
-- Args: [ Arg
--           { argCName = "method_name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the name of the XML-RPC method"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "params"
--           , argType = TCArray False (-1) 2 TGValue
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "arguments to @method"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "n_params"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of @params" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: [ Arg
--              { argCName = "n_params"
--              , argType = TBasicType TInt
--              , direction = DirectionIn
--              , mayBeNull = False
--              , argDoc =
--                  Documentation
--                    { rawDocText = Just "length of @params" , sinceVersion = Nothing }
--              , argScope = ScopeTypeInvalid
--              , argClosure = -1
--              , argDestroy = -1
--              , argCallerAllocates = False
--              , transfer = TransferNothing
--              }
--          ]
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_build_method_call" soup_xmlrpc_build_method_call :: 
    CString ->                              -- method_name : TBasicType TUTF8
    Ptr B.GValue.GValue ->                  -- params : TCArray False (-1) 2 TGValue
    Int32 ->                                -- n_params : TBasicType TInt
    IO CString

{-# DEPRECATED xmlrpcBuildMethodCall ["Use 'GI.Soup.Functions.xmlrpcBuildRequest' instead."] #-}
-- | This creates an XML-RPC methodCall and returns it as a string.
-- This is the low-level method that @/soup_xmlrpc_request_new()/@ is
-- built on.
-- 
-- /@params@/ is an array of t'GI.GObject.Structs.Value.Value' representing the parameters to
-- /@method@/. (It is *not* a t'GI.GObject.Structs.ValueArray.ValueArray', although if you have a
-- t'GI.GObject.Structs.ValueArray.ValueArray', you can just pass its \<literal>values\<\/literal>f and
-- \<literal>n_values\<\/literal> fields.)
-- 
-- The correspondence between glib types and XML-RPC types is:
-- 
--   int: @/int/@ (@/G_TYPE_INT/@)
--   boolean: t'P.Bool' (@/G_TYPE_BOOLEAN/@)
--   string: @/char/@* (@/G_TYPE_STRING/@)
--   double: @/double/@ (@/G_TYPE_DOUBLE/@)
--   datetime.iso8601: t'GI.Soup.Structs.Date.Date' (@/SOUP_TYPE_DATE/@)
--   base64: t'GI.GLib.Structs.ByteArray.ByteArray' (@/SOUP_TYPE_BYTE_ARRAY/@)
--   struct: t'GI.GLib.Structs.HashTable.HashTable' (@/G_TYPE_HASH_TABLE/@)
--   array: t'GI.GObject.Structs.ValueArray.ValueArray' (@/G_TYPE_VALUE_ARRAY/@)
-- 
-- For structs, use a t'GI.GLib.Structs.HashTable.HashTable' that maps strings to t'GI.GObject.Structs.Value.Value';
-- 'GI.Soup.Functions.valueHashNew' and related methods can help with this.
xmlrpcBuildMethodCall ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@methodName@/: the name of the XML-RPC method
    -> [GValue]
    -- ^ /@params@/: arguments to /@method@/
    -> m (Maybe T.Text)
    -- ^ __Returns:__ the text of the methodCall, or 'P.Nothing' on
    -- error
xmlrpcBuildMethodCall :: Text -> [GValue] -> m (Maybe Text)
xmlrpcBuildMethodCall Text
methodName [GValue]
params = IO (Maybe Text) -> m (Maybe Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe Text) -> m (Maybe Text))
-> IO (Maybe Text) -> m (Maybe Text)
forall a b. (a -> b) -> a -> b
$ do
    let nParams :: Int32
nParams = Int -> Int32
forall a b. (Integral a, Num b) => a -> b
fromIntegral (Int -> Int32) -> Int -> Int32
forall a b. (a -> b) -> a -> b
$ [GValue] -> Int
forall (t :: * -> *) a. Foldable t => t a -> Int
P.length [GValue]
params
    CString
methodName' <- Text -> IO CString
textToCString Text
methodName
    Ptr GValue
params' <- [GValue] -> IO (Ptr GValue)
B.GValue.packGValueArray [GValue]
params
    CString
result <- CString -> Ptr GValue -> Int32 -> IO CString
soup_xmlrpc_build_method_call CString
methodName' Ptr GValue
params' Int32
nParams
    Maybe Text
maybeResult <- CString -> (CString -> IO Text) -> IO (Maybe Text)
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull CString
result ((CString -> IO Text) -> IO (Maybe Text))
-> (CString -> IO Text) -> IO (Maybe Text)
forall a b. (a -> b) -> a -> b
$ \CString
result' -> do
        Text
result'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result'
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result''
    (GValue -> IO ()) -> [GValue] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ GValue -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [GValue]
params
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
methodName'
    (Int32 -> (Ptr GValue -> IO ()) -> Ptr GValue -> IO ()
forall a c.
Integral a =>
a -> (Ptr GValue -> IO c) -> Ptr GValue -> IO ()
B.GValue.mapGValueArrayWithLength Int32
nParams) Ptr GValue -> IO ()
B.GValue.unsetGValue Ptr GValue
params'
    Ptr GValue -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr GValue
params'
    Maybe Text -> IO (Maybe Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe Text
maybeResult


-- function websocket_server_process_handshake_with_extensions
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "#SoupMessage containing the client side of a WebSocket handshake"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "expected_origin"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "expected Origin header"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocols"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "allowed WebSocket\n  protocols."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "supported_extensions"
--           , argType =
--               TPtrArray
--                 (TInterface Name { namespace = "GObject" , name = "TypeClass" })
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "list\n  of supported extension types"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "accepted_extensions"
--           , argType =
--               TGList
--                 (TInterface
--                    Name { namespace = "Soup" , name = "WebsocketExtension" })
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a\n  #GList of #SoupWebsocketExtension objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_server_process_handshake_with_extensions" soup_websocket_server_process_handshake_with_extensions :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- expected_origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (GPtrArray (Ptr GObject.TypeClass.TypeClass)) -> -- supported_extensions : TPtrArray (TInterface (Name {namespace = "GObject", name = "TypeClass"}))
    Ptr (Ptr (GList (Ptr Soup.WebsocketExtension.WebsocketExtension))) -> -- accepted_extensions : TGList (TInterface (Name {namespace = "Soup", name = "WebsocketExtension"}))
    IO CInt

-- | Examines the method and request headers in /@msg@/ and (assuming /@msg@/
-- contains a valid handshake request), fills in the handshake
-- response.
-- 
-- If /@expectedOrigin@/ is non-'P.Nothing', then only requests containing a matching
-- \"Origin\" header will be accepted. If /@protocols@/ is non-'P.Nothing', then
-- only requests containing a compatible \"Sec-WebSocket-Protocols\"
-- header will be accepted. If /@supportedExtensions@/ is non-'P.Nothing', then
-- only requests containing valid supported extensions in
-- \"Sec-WebSocket-Extensions\" header will be accepted. The accepted extensions
-- will be returned in /@acceptedExtensions@/ parameter if non-'P.Nothing'.
-- 
-- This is a low-level function; if you use
-- 'GI.Soup.Objects.Server.serverAddWebsocketHandler' to handle accepting WebSocket
-- connections, it will call this for you.
-- 
-- /Since: 2.68/
websocketServerProcessHandshakeWithExtensions ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: t'GI.Soup.Objects.Message.Message' containing the client side of a WebSocket handshake
    -> Maybe (T.Text)
    -- ^ /@expectedOrigin@/: expected Origin header
    -> Maybe ([T.Text])
    -- ^ /@protocols@/: allowed WebSocket
    --   protocols.
    -> Maybe ([GObject.TypeClass.TypeClass])
    -- ^ /@supportedExtensions@/: list
    --   of supported extension types
    -> m ((Bool, [Soup.WebsocketExtension.WebsocketExtension]))
    -- ^ __Returns:__ 'P.True' if /@msg@/ contained a valid WebSocket handshake
    --   request and was updated to contain a handshake response. 'P.False' if not.
websocketServerProcessHandshakeWithExtensions :: a
-> Maybe Text
-> Maybe [Text]
-> Maybe [TypeClass]
-> m (Bool, [WebsocketExtension])
websocketServerProcessHandshakeWithExtensions a
msg Maybe Text
expectedOrigin Maybe [Text]
protocols Maybe [TypeClass]
supportedExtensions = IO (Bool, [WebsocketExtension]) -> m (Bool, [WebsocketExtension])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, [WebsocketExtension]) -> m (Bool, [WebsocketExtension]))
-> IO (Bool, [WebsocketExtension])
-> m (Bool, [WebsocketExtension])
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    CString
maybeExpectedOrigin <- case Maybe Text
expectedOrigin of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jExpectedOrigin -> do
            CString
jExpectedOrigin' <- Text -> IO CString
textToCString Text
jExpectedOrigin
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jExpectedOrigin'
    Ptr CString
maybeProtocols <- case Maybe [Text]
protocols of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jProtocols -> do
            Ptr CString
jProtocols' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jProtocols
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jProtocols'
    Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions <- case Maybe [TypeClass]
supportedExtensions of
        Maybe [TypeClass]
Nothing -> Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
forall a. Ptr a
nullPtr
        Just [TypeClass]
jSupportedExtensions -> do
            [Ptr TypeClass]
jSupportedExtensions' <- (TypeClass -> IO (Ptr TypeClass))
-> [TypeClass] -> IO [Ptr TypeClass]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [TypeClass]
jSupportedExtensions
            Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions'' <- [Ptr TypeClass] -> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr TypeClass]
jSupportedExtensions'
            Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions''
    Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions <- IO (Ptr (Ptr (GList (Ptr WebsocketExtension))))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr (GList (Ptr Soup.WebsocketExtension.WebsocketExtension))))
    CInt
result <- Ptr Message
-> CString
-> Ptr CString
-> Ptr (GPtrArray (Ptr TypeClass))
-> Ptr (Ptr (GList (Ptr WebsocketExtension)))
-> IO CInt
soup_websocket_server_process_handshake_with_extensions Ptr Message
msg' CString
maybeExpectedOrigin Ptr CString
maybeProtocols Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Ptr (GList (Ptr WebsocketExtension))
acceptedExtensions' <- Ptr (Ptr (GList (Ptr WebsocketExtension)))
-> IO (Ptr (GList (Ptr WebsocketExtension)))
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions
    [Ptr WebsocketExtension]
acceptedExtensions'' <- Ptr (GList (Ptr WebsocketExtension)) -> IO [Ptr WebsocketExtension]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr WebsocketExtension))
acceptedExtensions'
    [WebsocketExtension]
acceptedExtensions''' <- (Ptr WebsocketExtension -> IO WebsocketExtension)
-> [Ptr WebsocketExtension] -> IO [WebsocketExtension]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr WebsocketExtension -> WebsocketExtension)
-> Ptr WebsocketExtension -> IO WebsocketExtension
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr WebsocketExtension -> WebsocketExtension
Soup.WebsocketExtension.WebsocketExtension) [Ptr WebsocketExtension]
acceptedExtensions''
    Ptr (GList (Ptr WebsocketExtension)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr WebsocketExtension))
acceptedExtensions'
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    Maybe [TypeClass] -> ([TypeClass] -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe [TypeClass]
supportedExtensions ((TypeClass -> IO ()) -> [TypeClass] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr)
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeExpectedOrigin
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Ptr (GPtrArray (Ptr TypeClass)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
    Ptr (Ptr (GList (Ptr WebsocketExtension))) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions
    (Bool, [WebsocketExtension]) -> IO (Bool, [WebsocketExtension])
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', [WebsocketExtension]
acceptedExtensions''')


-- function websocket_server_process_handshake
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "#SoupMessage containing the client side of a WebSocket handshake"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "expected_origin"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "expected Origin header"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocols"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "allowed WebSocket\n  protocols."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_server_process_handshake" soup_websocket_server_process_handshake :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- expected_origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO CInt

-- | Examines the method and request headers in /@msg@/ and (assuming /@msg@/
-- contains a valid handshake request), fills in the handshake
-- response.
-- 
-- If /@expectedOrigin@/ is non-'P.Nothing', then only requests containing a matching
-- \"Origin\" header will be accepted. If /@protocols@/ is non-'P.Nothing', then
-- only requests containing a compatible \"Sec-WebSocket-Protocols\"
-- header will be accepted.
-- 
-- Requests containing \"Sec-WebSocket-Extensions\" header will be
-- accepted even if the header is not valid. To process a request
-- with extensions you need to use
-- 'GI.Soup.Functions.websocketServerProcessHandshakeWithExtensions' and provide
-- the list of supported extension types.
-- 
-- This is a low-level function; if you use
-- 'GI.Soup.Objects.Server.serverAddWebsocketHandler' to handle accepting WebSocket
-- connections, it will call this for you.
-- 
-- /Since: 2.50/
websocketServerProcessHandshake ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: t'GI.Soup.Objects.Message.Message' containing the client side of a WebSocket handshake
    -> Maybe (T.Text)
    -- ^ /@expectedOrigin@/: expected Origin header
    -> Maybe ([T.Text])
    -- ^ /@protocols@/: allowed WebSocket
    --   protocols.
    -> m Bool
    -- ^ __Returns:__ 'P.True' if /@msg@/ contained a valid WebSocket handshake
    --   request and was updated to contain a handshake response. 'P.False' if not.
websocketServerProcessHandshake :: a -> Maybe Text -> Maybe [Text] -> m Bool
websocketServerProcessHandshake a
msg Maybe Text
expectedOrigin Maybe [Text]
protocols = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    CString
maybeExpectedOrigin <- case Maybe Text
expectedOrigin of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jExpectedOrigin -> do
            CString
jExpectedOrigin' <- Text -> IO CString
textToCString Text
jExpectedOrigin
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jExpectedOrigin'
    Ptr CString
maybeProtocols <- case Maybe [Text]
protocols of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jProtocols -> do
            Ptr CString
jProtocols' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jProtocols
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jProtocols'
    CInt
result <- Ptr Message -> CString -> Ptr CString -> IO CInt
soup_websocket_server_process_handshake Ptr Message
msg' CString
maybeExpectedOrigin Ptr CString
maybeProtocols
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeExpectedOrigin
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function websocket_server_check_handshake_with_extensions
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "#SoupMessage containing the client side of a WebSocket handshake"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "expected Origin header"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocols"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "allowed WebSocket\n  protocols."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "supported_extensions"
--           , argType =
--               TPtrArray
--                 (TInterface Name { namespace = "GObject" , name = "TypeClass" })
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "list\n  of supported extension types"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_server_check_handshake_with_extensions" soup_websocket_server_check_handshake_with_extensions :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (GPtrArray (Ptr GObject.TypeClass.TypeClass)) -> -- supported_extensions : TPtrArray (TInterface (Name {namespace = "GObject", name = "TypeClass"}))
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Examines the method and request headers in /@msg@/ and determines
-- whether /@msg@/ contains a valid handshake request.
-- 
-- If /@origin@/ is non-'P.Nothing', then only requests containing a matching
-- \"Origin\" header will be accepted. If /@protocols@/ is non-'P.Nothing', then
-- only requests containing a compatible \"Sec-WebSocket-Protocols\"
-- header will be accepted. If /@supportedExtensions@/ is non-'P.Nothing', then
-- only requests containing valid supported extensions in
-- \"Sec-WebSocket-Extensions\" header will be accepted.
-- 
-- Normally @/soup_websocket_server_process_handshake_with_extensioins()/@
-- will take care of this for you, and if you use
-- 'GI.Soup.Objects.Server.serverAddWebsocketHandler' to handle accepting WebSocket
-- connections, it will call that for you. However, this function may
-- be useful if you need to perform more complicated validation; eg,
-- accepting multiple different Origins, or handling different protocols
-- depending on the path.
-- 
-- /Since: 2.68/
websocketServerCheckHandshakeWithExtensions ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: t'GI.Soup.Objects.Message.Message' containing the client side of a WebSocket handshake
    -> Maybe (T.Text)
    -- ^ /@origin@/: expected Origin header
    -> Maybe ([T.Text])
    -- ^ /@protocols@/: allowed WebSocket
    --   protocols.
    -> Maybe ([GObject.TypeClass.TypeClass])
    -- ^ /@supportedExtensions@/: list
    --   of supported extension types
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
websocketServerCheckHandshakeWithExtensions :: a -> Maybe Text -> Maybe [Text] -> Maybe [TypeClass] -> m ()
websocketServerCheckHandshakeWithExtensions a
msg Maybe Text
origin Maybe [Text]
protocols Maybe [TypeClass]
supportedExtensions = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    CString
maybeOrigin <- case Maybe Text
origin of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jOrigin -> do
            CString
jOrigin' <- Text -> IO CString
textToCString Text
jOrigin
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOrigin'
    Ptr CString
maybeProtocols <- case Maybe [Text]
protocols of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jProtocols -> do
            Ptr CString
jProtocols' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jProtocols
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jProtocols'
    Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions <- case Maybe [TypeClass]
supportedExtensions of
        Maybe [TypeClass]
Nothing -> Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
forall a. Ptr a
nullPtr
        Just [TypeClass]
jSupportedExtensions -> do
            [Ptr TypeClass]
jSupportedExtensions' <- (TypeClass -> IO (Ptr TypeClass))
-> [TypeClass] -> IO [Ptr TypeClass]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [TypeClass]
jSupportedExtensions
            Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions'' <- [Ptr TypeClass] -> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr TypeClass]
jSupportedExtensions'
            Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions''
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Message
-> CString
-> Ptr CString
-> Ptr (GPtrArray (Ptr TypeClass))
-> Ptr (Ptr GError)
-> IO CInt
soup_websocket_server_check_handshake_with_extensions Ptr Message
msg' CString
maybeOrigin Ptr CString
maybeProtocols Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
        Maybe [TypeClass] -> ([TypeClass] -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe [TypeClass]
supportedExtensions ((TypeClass -> IO ()) -> [TypeClass] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr)
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOrigin
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
        Ptr (GPtrArray (Ptr TypeClass)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOrigin
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
        Ptr (GPtrArray (Ptr TypeClass)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
     )


-- function websocket_server_check_handshake
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "#SoupMessage containing the client side of a WebSocket handshake"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "expected Origin header"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocols"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "allowed WebSocket\n  protocols."
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_server_check_handshake" soup_websocket_server_check_handshake :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Examines the method and request headers in /@msg@/ and determines
-- whether /@msg@/ contains a valid handshake request.
-- 
-- If /@origin@/ is non-'P.Nothing', then only requests containing a matching
-- \"Origin\" header will be accepted. If /@protocols@/ is non-'P.Nothing', then
-- only requests containing a compatible \"Sec-WebSocket-Protocols\"
-- header will be accepted.
-- 
-- Requests containing \"Sec-WebSocket-Extensions\" header will be
-- accepted even if the header is not valid. To check a request
-- with extensions you need to use
-- 'GI.Soup.Functions.websocketServerCheckHandshakeWithExtensions' and provide
-- the list of supported extension types.
-- 
-- Normally 'GI.Soup.Functions.websocketServerProcessHandshake' will take care
-- of this for you, and if you use 'GI.Soup.Objects.Server.serverAddWebsocketHandler'
-- to handle accepting WebSocket connections, it will call that for
-- you. However, this function may be useful if you need to perform
-- more complicated validation; eg, accepting multiple different Origins,
-- or handling different protocols depending on the path.
-- 
-- /Since: 2.50/
websocketServerCheckHandshake ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: t'GI.Soup.Objects.Message.Message' containing the client side of a WebSocket handshake
    -> Maybe (T.Text)
    -- ^ /@origin@/: expected Origin header
    -> Maybe ([T.Text])
    -- ^ /@protocols@/: allowed WebSocket
    --   protocols.
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
websocketServerCheckHandshake :: a -> Maybe Text -> Maybe [Text] -> m ()
websocketServerCheckHandshake a
msg Maybe Text
origin Maybe [Text]
protocols = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    CString
maybeOrigin <- case Maybe Text
origin of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jOrigin -> do
            CString
jOrigin' <- Text -> IO CString
textToCString Text
jOrigin
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOrigin'
    Ptr CString
maybeProtocols <- case Maybe [Text]
protocols of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jProtocols -> do
            Ptr CString
jProtocols' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jProtocols
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jProtocols'
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Message
-> CString -> Ptr CString -> Ptr (Ptr GError) -> IO CInt
soup_websocket_server_check_handshake Ptr Message
msg' CString
maybeOrigin Ptr CString
maybeProtocols
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOrigin
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOrigin
        (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
        Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
     )


-- function websocket_client_verify_handshake_with_extensions
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "#SoupMessage containing both client and server sides of a\n  WebSocket handshake"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "supported_extensions"
--           , argType =
--               TPtrArray
--                 (TInterface Name { namespace = "GObject" , name = "TypeClass" })
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "list\n  of supported extension types"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "accepted_extensions"
--           , argType =
--               TGList
--                 (TInterface
--                    Name { namespace = "Soup" , name = "WebsocketExtension" })
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a\n  #GList of #SoupWebsocketExtension objects"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_client_verify_handshake_with_extensions" soup_websocket_client_verify_handshake_with_extensions :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    Ptr (GPtrArray (Ptr GObject.TypeClass.TypeClass)) -> -- supported_extensions : TPtrArray (TInterface (Name {namespace = "GObject", name = "TypeClass"}))
    Ptr (Ptr (GList (Ptr Soup.WebsocketExtension.WebsocketExtension))) -> -- accepted_extensions : TGList (TInterface (Name {namespace = "Soup", name = "WebsocketExtension"}))
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Looks at the response status code and headers in /@msg@/ and
-- determines if they contain a valid WebSocket handshake response
-- (given the handshake request in /@msg@/\'s request headers).
-- 
-- If /@supportedExtensions@/ is non-'P.Nothing', extensions included in the
-- response \"Sec-WebSocket-Extensions\" are verified too. Accepted
-- extensions are returned in /@acceptedExtensions@/ parameter if non-'P.Nothing'.
-- 
-- This is a low-level function; if you use
-- 'GI.Soup.Objects.Session.sessionWebsocketConnectAsync' to create a WebSocket
-- connection, it will call this for you.
-- 
-- /Since: 2.68/
websocketClientVerifyHandshakeWithExtensions ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: t'GI.Soup.Objects.Message.Message' containing both client and server sides of a
    --   WebSocket handshake
    -> Maybe ([GObject.TypeClass.TypeClass])
    -- ^ /@supportedExtensions@/: list
    --   of supported extension types
    -> m ([Soup.WebsocketExtension.WebsocketExtension])
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
websocketClientVerifyHandshakeWithExtensions :: a -> Maybe [TypeClass] -> m [WebsocketExtension]
websocketClientVerifyHandshakeWithExtensions a
msg Maybe [TypeClass]
supportedExtensions = IO [WebsocketExtension] -> m [WebsocketExtension]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [WebsocketExtension] -> m [WebsocketExtension])
-> IO [WebsocketExtension] -> m [WebsocketExtension]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions <- case Maybe [TypeClass]
supportedExtensions of
        Maybe [TypeClass]
Nothing -> Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
forall a. Ptr a
nullPtr
        Just [TypeClass]
jSupportedExtensions -> do
            [Ptr TypeClass]
jSupportedExtensions' <- (TypeClass -> IO (Ptr TypeClass))
-> [TypeClass] -> IO [Ptr TypeClass]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [TypeClass]
jSupportedExtensions
            Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions'' <- [Ptr TypeClass] -> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr TypeClass]
jSupportedExtensions'
            Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions''
    Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions <- IO (Ptr (Ptr (GList (Ptr WebsocketExtension))))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr (GList (Ptr Soup.WebsocketExtension.WebsocketExtension))))
    IO [WebsocketExtension] -> IO () -> IO [WebsocketExtension]
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Message
-> Ptr (GPtrArray (Ptr TypeClass))
-> Ptr (Ptr (GList (Ptr WebsocketExtension)))
-> Ptr (Ptr GError)
-> IO CInt
soup_websocket_client_verify_handshake_with_extensions Ptr Message
msg' Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions
        Ptr (GList (Ptr WebsocketExtension))
acceptedExtensions' <- Ptr (Ptr (GList (Ptr WebsocketExtension)))
-> IO (Ptr (GList (Ptr WebsocketExtension)))
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions
        [Ptr WebsocketExtension]
acceptedExtensions'' <- Ptr (GList (Ptr WebsocketExtension)) -> IO [Ptr WebsocketExtension]
forall a. Ptr (GList (Ptr a)) -> IO [Ptr a]
unpackGList Ptr (GList (Ptr WebsocketExtension))
acceptedExtensions'
        [WebsocketExtension]
acceptedExtensions''' <- (Ptr WebsocketExtension -> IO WebsocketExtension)
-> [Ptr WebsocketExtension] -> IO [WebsocketExtension]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr WebsocketExtension -> WebsocketExtension)
-> Ptr WebsocketExtension -> IO WebsocketExtension
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr WebsocketExtension -> WebsocketExtension
Soup.WebsocketExtension.WebsocketExtension) [Ptr WebsocketExtension]
acceptedExtensions''
        Ptr (GList (Ptr WebsocketExtension)) -> IO ()
forall a. Ptr (GList a) -> IO ()
g_list_free Ptr (GList (Ptr WebsocketExtension))
acceptedExtensions'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
        Maybe [TypeClass] -> ([TypeClass] -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe [TypeClass]
supportedExtensions ((TypeClass -> IO ()) -> [TypeClass] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr)
        Ptr (GPtrArray (Ptr TypeClass)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
        Ptr (Ptr (GList (Ptr WebsocketExtension))) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions
        [WebsocketExtension] -> IO [WebsocketExtension]
forall (m :: * -> *) a. Monad m => a -> m a
return [WebsocketExtension]
acceptedExtensions'''
     ) (do
        Ptr (GPtrArray (Ptr TypeClass)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
        Ptr (Ptr (GList (Ptr WebsocketExtension))) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (GList (Ptr WebsocketExtension)))
acceptedExtensions
     )


-- function websocket_client_verify_handshake
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "#SoupMessage containing both client and server sides of a\n  WebSocket handshake"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_client_verify_handshake" soup_websocket_client_verify_handshake :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

-- | Looks at the response status code and headers in /@msg@/ and
-- determines if they contain a valid WebSocket handshake response
-- (given the handshake request in /@msg@/\'s request headers).
-- 
-- If the response contains the \"Sec-WebSocket-Extensions\" header,
-- the handshake will be considered invalid. You need to use
-- 'GI.Soup.Functions.websocketClientVerifyHandshakeWithExtensions' to handle
-- responses with extensions.
-- 
-- This is a low-level function; if you use
-- 'GI.Soup.Objects.Session.sessionWebsocketConnectAsync' to create a WebSocket
-- connection, it will call this for you.
-- 
-- /Since: 2.50/
websocketClientVerifyHandshake ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: t'GI.Soup.Objects.Message.Message' containing both client and server sides of a
    --   WebSocket handshake
    -> m ()
    -- ^ /(Can throw 'Data.GI.Base.GError.GError')/
websocketClientVerifyHandshake :: a -> m ()
websocketClientVerifyHandshake a
msg = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO a
onException (do
        CInt
_ <- (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CInt) -> IO CInt)
-> (Ptr (Ptr GError) -> IO CInt) -> IO CInt
forall a b. (a -> b) -> a -> b
$ Ptr Message -> Ptr (Ptr GError) -> IO CInt
soup_websocket_client_verify_handshake Ptr Message
msg'
        a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     ) (do
        () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()
     )


-- function websocket_client_prepare_handshake_with_extensions
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupMessage" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the \"Origin\" header to set"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocols"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "list of\n  protocols to offer"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "supported_extensions"
--           , argType =
--               TPtrArray
--                 (TInterface Name { namespace = "GObject" , name = "TypeClass" })
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "list\n  of supported extension types"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_client_prepare_handshake_with_extensions" soup_websocket_client_prepare_handshake_with_extensions :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (GPtrArray (Ptr GObject.TypeClass.TypeClass)) -> -- supported_extensions : TPtrArray (TInterface (Name {namespace = "GObject", name = "TypeClass"}))
    IO ()

-- | Adds the necessary headers to /@msg@/ to request a WebSocket
-- handshake including supported WebSocket extensions.
-- The message body and non-WebSocket-related headers are
-- not modified.
-- 
-- This is a low-level function; if you use
-- 'GI.Soup.Objects.Session.sessionWebsocketConnectAsync' to create a WebSocket
-- connection, it will call this for you.
-- 
-- /Since: 2.68/
websocketClientPrepareHandshakeWithExtensions ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: a t'GI.Soup.Objects.Message.Message'
    -> Maybe (T.Text)
    -- ^ /@origin@/: the \"Origin\" header to set
    -> Maybe ([T.Text])
    -- ^ /@protocols@/: list of
    --   protocols to offer
    -> Maybe ([GObject.TypeClass.TypeClass])
    -- ^ /@supportedExtensions@/: list
    --   of supported extension types
    -> m ()
websocketClientPrepareHandshakeWithExtensions :: a -> Maybe Text -> Maybe [Text] -> Maybe [TypeClass] -> m ()
websocketClientPrepareHandshakeWithExtensions a
msg Maybe Text
origin Maybe [Text]
protocols Maybe [TypeClass]
supportedExtensions = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    CString
maybeOrigin <- case Maybe Text
origin of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jOrigin -> do
            CString
jOrigin' <- Text -> IO CString
textToCString Text
jOrigin
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOrigin'
    Ptr CString
maybeProtocols <- case Maybe [Text]
protocols of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jProtocols -> do
            Ptr CString
jProtocols' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jProtocols
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jProtocols'
    Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions <- case Maybe [TypeClass]
supportedExtensions of
        Maybe [TypeClass]
Nothing -> Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
forall a. Ptr a
nullPtr
        Just [TypeClass]
jSupportedExtensions -> do
            [Ptr TypeClass]
jSupportedExtensions' <- (TypeClass -> IO (Ptr TypeClass))
-> [TypeClass] -> IO [Ptr TypeClass]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM TypeClass -> IO (Ptr TypeClass)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [TypeClass]
jSupportedExtensions
            Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions'' <- [Ptr TypeClass] -> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall a. [Ptr a] -> IO (Ptr (GPtrArray (Ptr a)))
packGPtrArray [Ptr TypeClass]
jSupportedExtensions'
            Ptr (GPtrArray (Ptr TypeClass))
-> IO (Ptr (GPtrArray (Ptr TypeClass)))
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr (GPtrArray (Ptr TypeClass))
jSupportedExtensions''
    Ptr Message
-> CString
-> Ptr CString
-> Ptr (GPtrArray (Ptr TypeClass))
-> IO ()
soup_websocket_client_prepare_handshake_with_extensions Ptr Message
msg' CString
maybeOrigin Ptr CString
maybeProtocols Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    Maybe [TypeClass] -> ([TypeClass] -> IO ()) -> IO ()
forall (m :: * -> *) a. Monad m => Maybe a -> (a -> m ()) -> m ()
whenJust Maybe [TypeClass]
supportedExtensions ((TypeClass -> IO ()) -> [TypeClass] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ TypeClass -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr)
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOrigin
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Ptr (GPtrArray (Ptr TypeClass)) -> IO ()
forall a. Ptr (GPtrArray a) -> IO ()
unrefPtrArray Ptr (GPtrArray (Ptr TypeClass))
maybeSupportedExtensions
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function websocket_client_prepare_handshake
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupMessage" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "origin"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the \"Origin\" header to set"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "protocols"
--           , argType = TCArray True (-1) (-1) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "list of\n  protocols to offer"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_client_prepare_handshake" soup_websocket_client_prepare_handshake :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    CString ->                              -- origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()

-- | Adds the necessary headers to /@msg@/ to request a WebSocket
-- handshake. The message body and non-WebSocket-related headers are
-- not modified.
-- 
-- Use 'GI.Soup.Functions.websocketClientPrepareHandshakeWithExtensions' if you
-- want to include \"Sec-WebSocket-Extensions\" header in the request.
-- 
-- This is a low-level function; if you use
-- 'GI.Soup.Objects.Session.sessionWebsocketConnectAsync' to create a WebSocket
-- connection, it will call this for you.
-- 
-- /Since: 2.50/
websocketClientPrepareHandshake ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: a t'GI.Soup.Objects.Message.Message'
    -> Maybe (T.Text)
    -- ^ /@origin@/: the \"Origin\" header to set
    -> Maybe ([T.Text])
    -- ^ /@protocols@/: list of
    --   protocols to offer
    -> m ()
websocketClientPrepareHandshake :: a -> Maybe Text -> Maybe [Text] -> m ()
websocketClientPrepareHandshake a
msg Maybe Text
origin Maybe [Text]
protocols = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    CString
maybeOrigin <- case Maybe Text
origin of
        Maybe Text
Nothing -> CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
forall a. Ptr a
nullPtr
        Just Text
jOrigin -> do
            CString
jOrigin' <- Text -> IO CString
textToCString Text
jOrigin
            CString -> IO CString
forall (m :: * -> *) a. Monad m => a -> m a
return CString
jOrigin'
    Ptr CString
maybeProtocols <- case Maybe [Text]
protocols of
        Maybe [Text]
Nothing -> Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
forall a. Ptr a
nullPtr
        Just [Text]
jProtocols -> do
            Ptr CString
jProtocols' <- [Text] -> IO (Ptr CString)
packZeroTerminatedUTF8CArray [Text]
jProtocols
            Ptr CString -> IO (Ptr CString)
forall (m :: * -> *) a. Monad m => a -> m a
return Ptr CString
jProtocols'
    Ptr Message -> CString -> Ptr CString -> IO ()
soup_websocket_client_prepare_handshake Ptr Message
msg' CString
maybeOrigin Ptr CString
maybeProtocols
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
maybeOrigin
    (CString -> IO ()) -> Ptr CString -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (Ptr a) -> IO ()
mapZeroTerminatedCArray CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
maybeProtocols
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function value_hash_new
-- XXX Could not generate function value_hash_new

-- Not implemented: GHashTable element of type TGValue unsupported.

-- function value_hash_insert_value
-- XXX Could not generate function value_hash_insert_value

-- Not implemented: GHashTable element of type TGValue unsupported.

-- function value_array_new
-- Args: []
-- Lengths: []
-- returnType: Just
--               (TInterface Name { namespace = "GObject" , name = "ValueArray" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_value_array_new" soup_value_array_new :: 
    IO (Ptr GObject.ValueArray.ValueArray)

{-# DEPRECATED valueArrayNew ["Use t'GVariant' API instead."] #-}
-- | Creates a new @/GValueArray/@. (This is just a wrapper around
-- 'GI.GObject.Structs.ValueArray.valueArrayNew', for naming consistency purposes.)
valueArrayNew ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m GObject.ValueArray.ValueArray
    -- ^ __Returns:__ a new @/GValueArray/@
valueArrayNew :: m ValueArray
valueArrayNew  = IO ValueArray -> m ValueArray
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ValueArray -> m ValueArray) -> IO ValueArray -> m ValueArray
forall a b. (a -> b) -> a -> b
$ do
    Ptr ValueArray
result <- IO (Ptr ValueArray)
soup_value_array_new
    Text -> Ptr ValueArray -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"valueArrayNew" Ptr ValueArray
result
    ValueArray
result' <- ((ManagedPtr ValueArray -> ValueArray)
-> Ptr ValueArray -> IO ValueArray
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr ValueArray -> ValueArray
GObject.ValueArray.ValueArray) Ptr ValueArray
result
    ValueArray -> IO ValueArray
forall (m :: * -> *) a. Monad m => a -> m a
return ValueArray
result'


-- function tld_get_base_domain
-- Args: [ Arg
--           { argCName = "hostname"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a hostname" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : True
-- Skip return : False

foreign import ccall "soup_tld_get_base_domain" soup_tld_get_base_domain :: 
    CString ->                              -- hostname : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CString

-- | Finds the base domain for a given /@hostname@/. The base domain is
-- composed by the top level domain (such as .org, .com, .co.uk, etc)
-- plus the second level domain, for example for myhost.mydomain.com
-- it will return mydomain.com.
-- 
-- Note that 'P.Nothing' will be returned for private URLs (those not ending
-- with any well known TLD) because choosing a base domain for them
-- would be totally arbitrary.
-- 
-- Prior to libsoup 2.46, this function required that /@hostname@/ be in
-- UTF-8 if it was an IDN. From 2.46 on, the name can be in either
-- UTF-8 or ASCII format (and the return value will be in the same
-- format).
-- 
-- /Since: 2.40/
tldGetBaseDomain ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@hostname@/: a hostname
    -> m T.Text
    -- ^ __Returns:__ a pointer to the start of the base domain in /@hostname@/. If
    -- an error occurs, 'P.Nothing' will be returned and /@error@/ set. /(Can throw 'Data.GI.Base.GError.GError')/
tldGetBaseDomain :: Text -> m Text
tldGetBaseDomain Text
hostname = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    CString
hostname' <- Text -> IO CString
textToCString Text
hostname
    IO Text -> IO () -> IO Text
forall a b. IO a -> IO b -> IO a
onException (do
        CString
result <- (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a. (Ptr (Ptr GError) -> IO a) -> IO a
propagateGError ((Ptr (Ptr GError) -> IO CString) -> IO CString)
-> (Ptr (Ptr GError) -> IO CString) -> IO CString
forall a b. (a -> b) -> a -> b
$ CString -> Ptr (Ptr GError) -> IO CString
soup_tld_get_base_domain CString
hostname'
        Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"tldGetBaseDomain" CString
result
        Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
        Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'
     ) (do
        CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
hostname'
     )


-- function tld_domain_is_public_suffix
-- Args: [ Arg
--           { argCName = "domain"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a domain name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_tld_domain_is_public_suffix" soup_tld_domain_is_public_suffix :: 
    CString ->                              -- domain : TBasicType TUTF8
    IO CInt

-- | Looks whether the /@domain@/ passed as argument is a public domain
-- suffix (.org, .com, .co.uk, etc) or not.
-- 
-- Prior to libsoup 2.46, this function required that /@domain@/ be in
-- UTF-8 if it was an IDN. From 2.46 on, the name can be in either
-- UTF-8 or ASCII format.
-- 
-- /Since: 2.40/
tldDomainIsPublicSuffix ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@domain@/: a domain name
    -> m Bool
    -- ^ __Returns:__ 'P.True' if it is a public domain, 'P.False' otherwise.
tldDomainIsPublicSuffix :: Text -> m Bool
tldDomainIsPublicSuffix Text
domain = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
domain' <- Text -> IO CString
textToCString Text
domain
    CInt
result <- CString -> IO CInt
soup_tld_domain_is_public_suffix CString
domain'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
domain'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function str_case_hash
-- Args: [ Arg
--           { argCName = "key"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "ASCII string to hash"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_str_case_hash" soup_str_case_hash :: 
    Ptr () ->                               -- key : TBasicType TPtr
    IO Word32

-- | Hashes /@key@/ in a case-insensitive manner.
strCaseHash ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@key@/: ASCII string to hash
    -> m Word32
    -- ^ __Returns:__ the hash code.
strCaseHash :: Ptr () -> m Word32
strCaseHash Ptr ()
key = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- Ptr () -> IO Word32
soup_str_case_hash Ptr ()
key
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function str_case_equal
-- Args: [ Arg
--           { argCName = "v1"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an ASCII string" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "v2"
--           , argType = TBasicType TPtr
--           , direction = DirectionIn
--           , mayBeNull = True
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "another ASCII string"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_str_case_equal" soup_str_case_equal :: 
    Ptr () ->                               -- v1 : TBasicType TPtr
    Ptr () ->                               -- v2 : TBasicType TPtr
    IO CInt

-- | Compares /@v1@/ and /@v2@/ in a case-insensitive manner
strCaseEqual ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Ptr ()
    -- ^ /@v1@/: an ASCII string
    -> Ptr ()
    -- ^ /@v2@/: another ASCII string
    -> m Bool
    -- ^ __Returns:__ 'P.True' if they are equal (modulo case)
strCaseEqual :: Ptr () -> Ptr () -> m Bool
strCaseEqual Ptr ()
v1 Ptr ()
v2 = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Ptr () -> Ptr () -> IO CInt
soup_str_case_equal Ptr ()
v1 Ptr ()
v2
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function http_error_quark
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt32)
-- throws : False
-- Skip return : False

foreign import ccall "soup_http_error_quark" soup_http_error_quark :: 
    IO Word32

-- | /No description available in the introspection data./
httpErrorQuark ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
httpErrorQuark :: m Word32
httpErrorQuark  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
soup_http_error_quark
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function headers_parse_status_line
-- Args: [ Arg
--           { argCName = "status_line"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "an HTTP Status-Line"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ver"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "HTTPVersion" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with the HTTP\nversion"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "status_code"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with\nthe status code"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "reason_phrase"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with\nthe reason phrase"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_headers_parse_status_line" soup_headers_parse_status_line :: 
    CString ->                              -- status_line : TBasicType TUTF8
    Ptr CUInt ->                            -- ver : TInterface (Name {namespace = "Soup", name = "HTTPVersion"})
    Ptr Word32 ->                           -- status_code : TBasicType TUInt
    Ptr CString ->                          -- reason_phrase : TBasicType TUTF8
    IO CInt

-- | Parses the HTTP Status-Line string in /@statusLine@/ into /@ver@/,
-- /@statusCode@/, and /@reasonPhrase@/. /@statusLine@/ must be terminated by
-- either \"\\0\" or \"\\r\\n\".
headersParseStatusLine ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@statusLine@/: an HTTP Status-Line
    -> m ((Bool, Soup.Enums.HTTPVersion, Word32, T.Text))
    -- ^ __Returns:__ 'P.True' if /@statusLine@/ was parsed successfully.
headersParseStatusLine :: Text -> m (Bool, HTTPVersion, Word32, Text)
headersParseStatusLine Text
statusLine = IO (Bool, HTTPVersion, Word32, Text)
-> m (Bool, HTTPVersion, Word32, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, HTTPVersion, Word32, Text)
 -> m (Bool, HTTPVersion, Word32, Text))
-> IO (Bool, HTTPVersion, Word32, Text)
-> m (Bool, HTTPVersion, Word32, Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
statusLine' <- Text -> IO CString
textToCString Text
statusLine
    Ptr CUInt
ver <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Ptr Word32
statusCode <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr CString
reasonPhrase <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    CInt
result <- CString -> Ptr CUInt -> Ptr Word32 -> Ptr CString -> IO CInt
soup_headers_parse_status_line CString
statusLine' Ptr CUInt
ver Ptr Word32
statusCode Ptr CString
reasonPhrase
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CUInt
ver' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
ver
    let ver'' :: HTTPVersion
ver'' = (Int -> HTTPVersion
forall a. Enum a => Int -> a
toEnum (Int -> HTTPVersion) -> (CUInt -> Int) -> CUInt -> HTTPVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
ver'
    Word32
statusCode' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
statusCode
    CString
reasonPhrase' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
reasonPhrase
    Text
reasonPhrase'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
reasonPhrase'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
reasonPhrase'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
statusLine'
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
ver
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
statusCode
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
reasonPhrase
    (Bool, HTTPVersion, Word32, Text)
-> IO (Bool, HTTPVersion, Word32, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', HTTPVersion
ver'', Word32
statusCode', Text
reasonPhrase'')


-- function headers_parse_response
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the headers (up to, but not including, the trailing blank line)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of @str" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "headers"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "MessageHeaders" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "#SoupMessageHeaders to store the header values in"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "ver"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "HTTPVersion" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with the HTTP\nversion"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "status_code"
--           , argType = TBasicType TUInt
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with\nthe status code"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "reason_phrase"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with\nthe reason phrase"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_headers_parse_response" soup_headers_parse_response :: 
    CString ->                              -- str : TBasicType TUTF8
    Int32 ->                                -- len : TBasicType TInt
    Ptr Soup.MessageHeaders.MessageHeaders -> -- headers : TInterface (Name {namespace = "Soup", name = "MessageHeaders"})
    Ptr CUInt ->                            -- ver : TInterface (Name {namespace = "Soup", name = "HTTPVersion"})
    Ptr Word32 ->                           -- status_code : TBasicType TUInt
    Ptr CString ->                          -- reason_phrase : TBasicType TUTF8
    IO CInt

-- | Parses the headers of an HTTP response in /@str@/ and stores the
-- results in /@ver@/, /@statusCode@/, /@reasonPhrase@/, and /@headers@/.
-- 
-- Beware that /@headers@/ may be modified even on failure.
headersParseResponse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the headers (up to, but not including, the trailing blank line)
    -> Int32
    -- ^ /@len@/: length of /@str@/
    -> Soup.MessageHeaders.MessageHeaders
    -- ^ /@headers@/: t'GI.Soup.Structs.MessageHeaders.MessageHeaders' to store the header values in
    -> m ((Bool, Soup.Enums.HTTPVersion, Word32, T.Text))
    -- ^ __Returns:__ success or failure.
headersParseResponse :: Text
-> Int32 -> MessageHeaders -> m (Bool, HTTPVersion, Word32, Text)
headersParseResponse Text
str Int32
len MessageHeaders
headers = IO (Bool, HTTPVersion, Word32, Text)
-> m (Bool, HTTPVersion, Word32, Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Bool, HTTPVersion, Word32, Text)
 -> m (Bool, HTTPVersion, Word32, Text))
-> IO (Bool, HTTPVersion, Word32, Text)
-> m (Bool, HTTPVersion, Word32, Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    Ptr MessageHeaders
headers' <- MessageHeaders -> IO (Ptr MessageHeaders)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MessageHeaders
headers
    Ptr CUInt
ver <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Ptr Word32
statusCode <- IO (Ptr Word32)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr Word32)
    Ptr CString
reasonPhrase <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    CInt
result <- CString
-> Int32
-> Ptr MessageHeaders
-> Ptr CUInt
-> Ptr Word32
-> Ptr CString
-> IO CInt
soup_headers_parse_response CString
str' Int32
len Ptr MessageHeaders
headers' Ptr CUInt
ver Ptr Word32
statusCode Ptr CString
reasonPhrase
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CUInt
ver' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
ver
    let ver'' :: HTTPVersion
ver'' = (Int -> HTTPVersion
forall a. Enum a => Int -> a
toEnum (Int -> HTTPVersion) -> (CUInt -> Int) -> CUInt -> HTTPVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
ver'
    Word32
statusCode' <- Ptr Word32 -> IO Word32
forall a. Storable a => Ptr a -> IO a
peek Ptr Word32
statusCode
    CString
reasonPhrase' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
reasonPhrase
    Text
reasonPhrase'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
reasonPhrase'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
reasonPhrase'
    MessageHeaders -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MessageHeaders
headers
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
ver
    Ptr Word32 -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr Word32
statusCode
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
reasonPhrase
    (Bool, HTTPVersion, Word32, Text)
-> IO (Bool, HTTPVersion, Word32, Text)
forall (m :: * -> *) a. Monad m => a -> m a
return (Bool
result', HTTPVersion
ver'', Word32
statusCode', Text
reasonPhrase'')


-- function headers_parse_request
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the headers (up to, but not including, the trailing blank line)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of @str" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "req_headers"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "MessageHeaders" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "#SoupMessageHeaders to store the header values in"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "req_method"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with the\nrequest method"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "req_path"
--           , argType = TBasicType TUTF8
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with the\nrequest path"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       , Arg
--           { argCName = "ver"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "HTTPVersion" }
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "if non-%NULL, will be filled in with the HTTP\nversion"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_headers_parse_request" soup_headers_parse_request :: 
    CString ->                              -- str : TBasicType TUTF8
    Int32 ->                                -- len : TBasicType TInt
    Ptr Soup.MessageHeaders.MessageHeaders -> -- req_headers : TInterface (Name {namespace = "Soup", name = "MessageHeaders"})
    Ptr CString ->                          -- req_method : TBasicType TUTF8
    Ptr CString ->                          -- req_path : TBasicType TUTF8
    Ptr CUInt ->                            -- ver : TInterface (Name {namespace = "Soup", name = "HTTPVersion"})
    IO Word32

-- | Parses the headers of an HTTP request in /@str@/ and stores the
-- results in /@reqMethod@/, /@reqPath@/, /@ver@/, and /@reqHeaders@/.
-- 
-- Beware that /@reqHeaders@/ may be modified even on failure.
headersParseRequest ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the headers (up to, but not including, the trailing blank line)
    -> Int32
    -- ^ /@len@/: length of /@str@/
    -> Soup.MessageHeaders.MessageHeaders
    -- ^ /@reqHeaders@/: t'GI.Soup.Structs.MessageHeaders.MessageHeaders' to store the header values in
    -> m ((Word32, T.Text, T.Text, Soup.Enums.HTTPVersion))
    -- ^ __Returns:__ 'GI.Soup.Enums.StatusOk' if the headers could be parsed, or an
    -- HTTP error to be returned to the client if they could not be.
headersParseRequest :: Text
-> Int32 -> MessageHeaders -> m (Word32, Text, Text, HTTPVersion)
headersParseRequest Text
str Int32
len MessageHeaders
reqHeaders = IO (Word32, Text, Text, HTTPVersion)
-> m (Word32, Text, Text, HTTPVersion)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Word32, Text, Text, HTTPVersion)
 -> m (Word32, Text, Text, HTTPVersion))
-> IO (Word32, Text, Text, HTTPVersion)
-> m (Word32, Text, Text, HTTPVersion)
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    Ptr MessageHeaders
reqHeaders' <- MessageHeaders -> IO (Ptr MessageHeaders)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MessageHeaders
reqHeaders
    Ptr CString
reqMethod <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    Ptr CString
reqPath <- IO (Ptr CString)
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr CString)
    Ptr CUInt
ver <- IO (Ptr CUInt)
forall a. Storable a => IO (Ptr a)
allocMem :: IO (Ptr CUInt)
    Word32
result <- CString
-> Int32
-> Ptr MessageHeaders
-> Ptr CString
-> Ptr CString
-> Ptr CUInt
-> IO Word32
soup_headers_parse_request CString
str' Int32
len Ptr MessageHeaders
reqHeaders' Ptr CString
reqMethod Ptr CString
reqPath Ptr CUInt
ver
    CString
reqMethod' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
reqMethod
    Text
reqMethod'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
reqMethod'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
reqMethod'
    CString
reqPath' <- Ptr CString -> IO CString
forall a. Storable a => Ptr a -> IO a
peek Ptr CString
reqPath
    Text
reqPath'' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
reqPath'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
reqPath'
    CUInt
ver' <- Ptr CUInt -> IO CUInt
forall a. Storable a => Ptr a -> IO a
peek Ptr CUInt
ver
    let ver'' :: HTTPVersion
ver'' = (Int -> HTTPVersion
forall a. Enum a => Int -> a
toEnum (Int -> HTTPVersion) -> (CUInt -> Int) -> CUInt -> HTTPVersion
forall b c a. (b -> c) -> (a -> b) -> a -> c
. CUInt -> Int
forall a b. (Integral a, Num b) => a -> b
fromIntegral) CUInt
ver'
    MessageHeaders -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MessageHeaders
reqHeaders
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
reqMethod
    Ptr CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CString
reqPath
    Ptr CUInt -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr CUInt
ver
    (Word32, Text, Text, HTTPVersion)
-> IO (Word32, Text, Text, HTTPVersion)
forall (m :: * -> *) a. Monad m => a -> m a
return (Word32
result, Text
reqMethod'', Text
reqPath'', HTTPVersion
ver'')


-- function headers_parse
-- Args: [ Arg
--           { argCName = "str"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "the header string (including the Request-Line or Status-Line,\n  but not the trailing blank line)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "len"
--           , argType = TBasicType TInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "length of @str" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "dest"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "MessageHeaders" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "#SoupMessageHeaders to store the header values in"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_headers_parse" soup_headers_parse :: 
    CString ->                              -- str : TBasicType TUTF8
    Int32 ->                                -- len : TBasicType TInt
    Ptr Soup.MessageHeaders.MessageHeaders -> -- dest : TInterface (Name {namespace = "Soup", name = "MessageHeaders"})
    IO CInt

-- | Parses the headers of an HTTP request or response in /@str@/ and
-- stores the results in /@dest@/. Beware that /@dest@/ may be modified even
-- on failure.
-- 
-- This is a low-level method; normally you would use
-- 'GI.Soup.Functions.headersParseRequest' or 'GI.Soup.Functions.headersParseResponse'.
-- 
-- /Since: 2.26/
headersParse ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@str@/: the header string (including the Request-Line or Status-Line,
    --   but not the trailing blank line)
    -> Int32
    -- ^ /@len@/: length of /@str@/
    -> Soup.MessageHeaders.MessageHeaders
    -- ^ /@dest@/: t'GI.Soup.Structs.MessageHeaders.MessageHeaders' to store the header values in
    -> m Bool
    -- ^ __Returns:__ success or failure
headersParse :: Text -> Int32 -> MessageHeaders -> m Bool
headersParse Text
str Int32
len MessageHeaders
dest = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
str' <- Text -> IO CString
textToCString Text
str
    Ptr MessageHeaders
dest' <- MessageHeaders -> IO (Ptr MessageHeaders)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr MessageHeaders
dest
    CInt
result <- CString -> Int32 -> Ptr MessageHeaders -> IO CInt
soup_headers_parse CString
str' Int32
len Ptr MessageHeaders
dest'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    MessageHeaders -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr MessageHeaders
dest
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
str'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function header_parse_semi_param_list_strict
-- Args: [ Arg
--           { argCName = "header"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a header value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGHash (TBasicType TUTF8) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_parse_semi_param_list_strict" soup_header_parse_semi_param_list_strict :: 
    CString ->                              -- header : TBasicType TUTF8
    IO (Ptr (GHashTable CString CString))

-- | A strict version of 'GI.Soup.Functions.headerParseSemiParamList'
-- that bails out if there are duplicate parameters.
-- Note that this function will treat RFC5987-encoded
-- parameters as duplicated if an ASCII version is also
-- present. For header fields that might contain
-- RFC5987-encoded parameters, use
-- 'GI.Soup.Functions.headerParseSemiParamList' instead.
-- 
-- /Since: 2.66/
headerParseSemiParamListStrict ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@header@/: a header value
    -> m (Maybe (Map.Map T.Text T.Text))
    -- ^ __Returns:__ 
    -- a t'GI.GLib.Structs.HashTable.HashTable' of list elements, which can be freed with
    -- 'GI.Soup.Functions.headerFreeParamList' or 'P.Nothing' if there are duplicate
    -- elements.
headerParseSemiParamListStrict :: Text -> m (Maybe (Map Text Text))
headerParseSemiParamListStrict Text
header = IO (Maybe (Map Text Text)) -> m (Maybe (Map Text Text))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (Map Text Text)) -> m (Maybe (Map Text Text)))
-> IO (Maybe (Map Text Text)) -> m (Maybe (Map Text Text))
forall a b. (a -> b) -> a -> b
$ do
    CString
header' <- Text -> IO CString
textToCString Text
header
    Ptr (GHashTable CString CString)
result <- CString -> IO (Ptr (GHashTable CString CString))
soup_header_parse_semi_param_list_strict CString
header'
    Maybe (Map Text Text)
maybeResult <- Ptr (GHashTable CString CString)
-> (Ptr (GHashTable CString CString) -> IO (Map Text Text))
-> IO (Maybe (Map Text Text))
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr (GHashTable CString CString)
result ((Ptr (GHashTable CString CString) -> IO (Map Text Text))
 -> IO (Maybe (Map Text Text)))
-> (Ptr (GHashTable CString CString) -> IO (Map Text Text))
-> IO (Maybe (Map Text Text))
forall a b. (a -> b) -> a -> b
$ \Ptr (GHashTable CString CString)
result' -> do
        [(PtrWrapped CString, PtrWrapped CString)]
result'' <- Ptr (GHashTable CString CString)
-> IO [(PtrWrapped CString, PtrWrapped CString)]
forall a b.
Ptr (GHashTable a b) -> IO [(PtrWrapped a, PtrWrapped b)]
unpackGHashTable Ptr (GHashTable CString CString)
result'
        let result''' :: [(CString, PtrWrapped CString)]
result''' = (PtrWrapped CString -> CString)
-> [(PtrWrapped CString, PtrWrapped CString)]
-> [(CString, PtrWrapped CString)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst PtrWrapped CString -> CString
cstringUnpackPtr [(PtrWrapped CString, PtrWrapped CString)]
result''
        [(Text, PtrWrapped CString)]
result'''' <- (CString -> IO Text)
-> [(CString, PtrWrapped CString)]
-> IO [(Text, PtrWrapped CString)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(CString, PtrWrapped CString)]
result'''
        let result''''' :: [(Text, CString)]
result''''' = (PtrWrapped CString -> CString)
-> [(Text, PtrWrapped CString)] -> [(Text, CString)]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond PtrWrapped CString -> CString
cstringUnpackPtr [(Text, PtrWrapped CString)]
result''''
        [(Text, Text)]
result'''''' <- (CString -> IO Text) -> [(Text, CString)] -> IO [(Text, Text)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(Text, CString)]
result'''''
        let result''''''' :: Map Text Text
result''''''' = [(Text, Text)] -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Text, Text)]
result''''''
        Ptr (GHashTable CString CString) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString CString)
result'
        Map Text Text -> IO (Map Text Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Map Text Text
result'''''''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
header'
    Maybe (Map Text Text) -> IO (Maybe (Map Text Text))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (Map Text Text)
maybeResult


-- function header_parse_semi_param_list
-- Args: [ Arg
--           { argCName = "header"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a header value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGHash (TBasicType TUTF8) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_parse_semi_param_list" soup_header_parse_semi_param_list :: 
    CString ->                              -- header : TBasicType TUTF8
    IO (Ptr (GHashTable CString CString))

-- | Parses a header which is a semicolon-delimited list of something
-- like: \<literal>token [ \"=\" ( token | quoted-string ) ]\<\/literal>.
-- 
-- Tokens that don\'t have an associated value will still be added to
-- the resulting hash table, but with a 'P.Nothing' value.
-- 
-- This also handles RFC5987 encoding (which in HTTP is mostly used
-- for giving UTF8-encoded filenames in the Content-Disposition
-- header).
-- 
-- /Since: 2.24/
headerParseSemiParamList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@header@/: a header value
    -> m (Map.Map T.Text T.Text)
    -- ^ __Returns:__ a
    -- t'GI.GLib.Structs.HashTable.HashTable' of list elements, which can be freed with
    -- 'GI.Soup.Functions.headerFreeParamList'.
headerParseSemiParamList :: Text -> m (Map Text Text)
headerParseSemiParamList Text
header = IO (Map Text Text) -> m (Map Text Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Map Text Text) -> m (Map Text Text))
-> IO (Map Text Text) -> m (Map Text Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
header' <- Text -> IO CString
textToCString Text
header
    Ptr (GHashTable CString CString)
result <- CString -> IO (Ptr (GHashTable CString CString))
soup_header_parse_semi_param_list CString
header'
    Text -> Ptr (GHashTable CString CString) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"headerParseSemiParamList" Ptr (GHashTable CString CString)
result
    [(PtrWrapped CString, PtrWrapped CString)]
result' <- Ptr (GHashTable CString CString)
-> IO [(PtrWrapped CString, PtrWrapped CString)]
forall a b.
Ptr (GHashTable a b) -> IO [(PtrWrapped a, PtrWrapped b)]
unpackGHashTable Ptr (GHashTable CString CString)
result
    let result'' :: [(CString, PtrWrapped CString)]
result'' = (PtrWrapped CString -> CString)
-> [(PtrWrapped CString, PtrWrapped CString)]
-> [(CString, PtrWrapped CString)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst PtrWrapped CString -> CString
cstringUnpackPtr [(PtrWrapped CString, PtrWrapped CString)]
result'
    [(Text, PtrWrapped CString)]
result''' <- (CString -> IO Text)
-> [(CString, PtrWrapped CString)]
-> IO [(Text, PtrWrapped CString)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(CString, PtrWrapped CString)]
result''
    let result'''' :: [(Text, CString)]
result'''' = (PtrWrapped CString -> CString)
-> [(Text, PtrWrapped CString)] -> [(Text, CString)]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond PtrWrapped CString -> CString
cstringUnpackPtr [(Text, PtrWrapped CString)]
result'''
    [(Text, Text)]
result''''' <- (CString -> IO Text) -> [(Text, CString)] -> IO [(Text, Text)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(Text, CString)]
result''''
    let result'''''' :: Map Text Text
result'''''' = [(Text, Text)] -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Text, Text)]
result'''''
    Ptr (GHashTable CString CString) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString CString)
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
header'
    Map Text Text -> IO (Map Text Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Map Text Text
result''''''


-- function header_parse_quality_list
-- Args: [ Arg
--           { argCName = "header"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a header value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "unacceptable"
--           , argType = TGSList (TBasicType TUTF8)
--           , direction = DirectionOut
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "on\nreturn, will contain a list of unacceptable values"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferEverything
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGSList (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_parse_quality_list" soup_header_parse_quality_list :: 
    CString ->                              -- header : TBasicType TUTF8
    Ptr (Ptr (GSList CString)) ->           -- unacceptable : TGSList (TBasicType TUTF8)
    IO (Ptr (GSList CString))

-- | Parses a header whose content is a list of items with optional
-- \"qvalue\"s (eg, Accept, Accept-Charset, Accept-Encoding,
-- Accept-Language, TE).
-- 
-- If /@unacceptable@/ is not 'P.Nothing', then on return, it will contain the
-- items with qvalue 0. Either way, those items will be removed from
-- the main list.
headerParseQualityList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@header@/: a header value
    -> m (([T.Text], [T.Text]))
    -- ^ __Returns:__ a t'GI.GLib.Structs.SList.SList' of
    -- acceptable values (as allocated strings), highest-qvalue first.
headerParseQualityList :: Text -> m ([Text], [Text])
headerParseQualityList Text
header = IO ([Text], [Text]) -> m ([Text], [Text])
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO ([Text], [Text]) -> m ([Text], [Text]))
-> IO ([Text], [Text]) -> m ([Text], [Text])
forall a b. (a -> b) -> a -> b
$ do
    CString
header' <- Text -> IO CString
textToCString Text
header
    Ptr (Ptr (GSList CString))
unacceptable <- IO (Ptr (Ptr (GSList CString)))
forall a. Storable a => IO (Ptr a)
callocMem :: IO (Ptr (Ptr (GSList CString)))
    Ptr (GSList CString)
result <- CString -> Ptr (Ptr (GSList CString)) -> IO (Ptr (GSList CString))
soup_header_parse_quality_list CString
header' Ptr (Ptr (GSList CString))
unacceptable
    [CString]
result' <- Ptr (GSList CString) -> IO [CString]
forall a. Ptr (GSList (Ptr a)) -> IO [Ptr a]
unpackGSList Ptr (GSList CString)
result
    [Text]
result'' <- (CString -> IO Text) -> [CString] -> IO [Text]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [CString]
result'
    (CString -> IO ()) -> Ptr (GSList CString) -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (GSList (Ptr a)) -> IO ()
mapGSList CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (GSList CString)
result
    Ptr (GSList CString) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList CString)
result
    Ptr (GSList CString)
unacceptable' <- Ptr (Ptr (GSList CString)) -> IO (Ptr (GSList CString))
forall a. Storable a => Ptr a -> IO a
peek Ptr (Ptr (GSList CString))
unacceptable
    [CString]
unacceptable'' <- Ptr (GSList CString) -> IO [CString]
forall a. Ptr (GSList (Ptr a)) -> IO [Ptr a]
unpackGSList Ptr (GSList CString)
unacceptable'
    [Text]
unacceptable''' <- (CString -> IO Text) -> [CString] -> IO [Text]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [CString]
unacceptable''
    (CString -> IO ()) -> Ptr (GSList CString) -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (GSList (Ptr a)) -> IO ()
mapGSList CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (GSList CString)
unacceptable'
    Ptr (GSList CString) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList CString)
unacceptable'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
header'
    Ptr (Ptr (GSList CString)) -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (Ptr (GSList CString))
unacceptable
    ([Text], [Text]) -> IO ([Text], [Text])
forall (m :: * -> *) a. Monad m => a -> m a
return ([Text]
result'', [Text]
unacceptable''')


-- function header_parse_param_list_strict
-- Args: [ Arg
--           { argCName = "header"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a header value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGHash (TBasicType TUTF8) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_parse_param_list_strict" soup_header_parse_param_list_strict :: 
    CString ->                              -- header : TBasicType TUTF8
    IO (Ptr (GHashTable CString CString))

-- | A strict version of 'GI.Soup.Functions.headerParseParamList'
-- that bails out if there are duplicate parameters.
-- Note that this function will treat RFC5987-encoded
-- parameters as duplicated if an ASCII version is also
-- present. For header fields that might contain
-- RFC5987-encoded parameters, use
-- 'GI.Soup.Functions.headerParseParamList' instead.
-- 
-- /Since: 2.66/
headerParseParamListStrict ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@header@/: a header value
    -> m (Maybe (Map.Map T.Text T.Text))
    -- ^ __Returns:__ 
    -- a t'GI.GLib.Structs.HashTable.HashTable' of list elements, which can be freed with
    -- 'GI.Soup.Functions.headerFreeParamList' or 'P.Nothing' if there are duplicate
    -- elements.
headerParseParamListStrict :: Text -> m (Maybe (Map Text Text))
headerParseParamListStrict Text
header = IO (Maybe (Map Text Text)) -> m (Maybe (Map Text Text))
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Maybe (Map Text Text)) -> m (Maybe (Map Text Text)))
-> IO (Maybe (Map Text Text)) -> m (Maybe (Map Text Text))
forall a b. (a -> b) -> a -> b
$ do
    CString
header' <- Text -> IO CString
textToCString Text
header
    Ptr (GHashTable CString CString)
result <- CString -> IO (Ptr (GHashTable CString CString))
soup_header_parse_param_list_strict CString
header'
    Maybe (Map Text Text)
maybeResult <- Ptr (GHashTable CString CString)
-> (Ptr (GHashTable CString CString) -> IO (Map Text Text))
-> IO (Maybe (Map Text Text))
forall a b. Ptr a -> (Ptr a -> IO b) -> IO (Maybe b)
convertIfNonNull Ptr (GHashTable CString CString)
result ((Ptr (GHashTable CString CString) -> IO (Map Text Text))
 -> IO (Maybe (Map Text Text)))
-> (Ptr (GHashTable CString CString) -> IO (Map Text Text))
-> IO (Maybe (Map Text Text))
forall a b. (a -> b) -> a -> b
$ \Ptr (GHashTable CString CString)
result' -> do
        [(PtrWrapped CString, PtrWrapped CString)]
result'' <- Ptr (GHashTable CString CString)
-> IO [(PtrWrapped CString, PtrWrapped CString)]
forall a b.
Ptr (GHashTable a b) -> IO [(PtrWrapped a, PtrWrapped b)]
unpackGHashTable Ptr (GHashTable CString CString)
result'
        let result''' :: [(CString, PtrWrapped CString)]
result''' = (PtrWrapped CString -> CString)
-> [(PtrWrapped CString, PtrWrapped CString)]
-> [(CString, PtrWrapped CString)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst PtrWrapped CString -> CString
cstringUnpackPtr [(PtrWrapped CString, PtrWrapped CString)]
result''
        [(Text, PtrWrapped CString)]
result'''' <- (CString -> IO Text)
-> [(CString, PtrWrapped CString)]
-> IO [(Text, PtrWrapped CString)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(CString, PtrWrapped CString)]
result'''
        let result''''' :: [(Text, CString)]
result''''' = (PtrWrapped CString -> CString)
-> [(Text, PtrWrapped CString)] -> [(Text, CString)]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond PtrWrapped CString -> CString
cstringUnpackPtr [(Text, PtrWrapped CString)]
result''''
        [(Text, Text)]
result'''''' <- (CString -> IO Text) -> [(Text, CString)] -> IO [(Text, Text)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(Text, CString)]
result'''''
        let result''''''' :: Map Text Text
result''''''' = [(Text, Text)] -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Text, Text)]
result''''''
        Ptr (GHashTable CString CString) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString CString)
result'
        Map Text Text -> IO (Map Text Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Map Text Text
result'''''''
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
header'
    Maybe (Map Text Text) -> IO (Maybe (Map Text Text))
forall (m :: * -> *) a. Monad m => a -> m a
return Maybe (Map Text Text)
maybeResult


-- function header_parse_param_list
-- Args: [ Arg
--           { argCName = "header"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a header value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGHash (TBasicType TUTF8) (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_parse_param_list" soup_header_parse_param_list :: 
    CString ->                              -- header : TBasicType TUTF8
    IO (Ptr (GHashTable CString CString))

-- | Parses a header which is a comma-delimited list of something like:
-- \<literal>token [ \"=\" ( token | quoted-string ) ]\<\/literal>.
-- 
-- Tokens that don\'t have an associated value will still be added to
-- the resulting hash table, but with a 'P.Nothing' value.
-- 
-- This also handles RFC5987 encoding (which in HTTP is mostly used
-- for giving UTF8-encoded filenames in the Content-Disposition
-- header).
headerParseParamList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@header@/: a header value
    -> m (Map.Map T.Text T.Text)
    -- ^ __Returns:__ a
    -- t'GI.GLib.Structs.HashTable.HashTable' of list elements, which can be freed with
    -- 'GI.Soup.Functions.headerFreeParamList'.
headerParseParamList :: Text -> m (Map Text Text)
headerParseParamList Text
header = IO (Map Text Text) -> m (Map Text Text)
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO (Map Text Text) -> m (Map Text Text))
-> IO (Map Text Text) -> m (Map Text Text)
forall a b. (a -> b) -> a -> b
$ do
    CString
header' <- Text -> IO CString
textToCString Text
header
    Ptr (GHashTable CString CString)
result <- CString -> IO (Ptr (GHashTable CString CString))
soup_header_parse_param_list CString
header'
    Text -> Ptr (GHashTable CString CString) -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"headerParseParamList" Ptr (GHashTable CString CString)
result
    [(PtrWrapped CString, PtrWrapped CString)]
result' <- Ptr (GHashTable CString CString)
-> IO [(PtrWrapped CString, PtrWrapped CString)]
forall a b.
Ptr (GHashTable a b) -> IO [(PtrWrapped a, PtrWrapped b)]
unpackGHashTable Ptr (GHashTable CString CString)
result
    let result'' :: [(CString, PtrWrapped CString)]
result'' = (PtrWrapped CString -> CString)
-> [(PtrWrapped CString, PtrWrapped CString)]
-> [(CString, PtrWrapped CString)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst PtrWrapped CString -> CString
cstringUnpackPtr [(PtrWrapped CString, PtrWrapped CString)]
result'
    [(Text, PtrWrapped CString)]
result''' <- (CString -> IO Text)
-> [(CString, PtrWrapped CString)]
-> IO [(Text, PtrWrapped CString)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(CString, PtrWrapped CString)]
result''
    let result'''' :: [(Text, CString)]
result'''' = (PtrWrapped CString -> CString)
-> [(Text, PtrWrapped CString)] -> [(Text, CString)]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond PtrWrapped CString -> CString
cstringUnpackPtr [(Text, PtrWrapped CString)]
result'''
    [(Text, Text)]
result''''' <- (CString -> IO Text) -> [(Text, CString)] -> IO [(Text, Text)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [(Text, CString)]
result''''
    let result'''''' :: Map Text Text
result'''''' = [(Text, Text)] -> Map Text Text
forall k a. Ord k => [(k, a)] -> Map k a
Map.fromList [(Text, Text)]
result'''''
    Ptr (GHashTable CString CString) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString CString)
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
header'
    Map Text Text -> IO (Map Text Text)
forall (m :: * -> *) a. Monad m => a -> m a
return Map Text Text
result''''''


-- function header_parse_list
-- Args: [ Arg
--           { argCName = "header"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a header value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TGSList (TBasicType TUTF8))
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_parse_list" soup_header_parse_list :: 
    CString ->                              -- header : TBasicType TUTF8
    IO (Ptr (GSList CString))

-- | Parses a header whose content is described by RFC2616 as
-- \"@/something/@\", where \"something\" does not itself contain commas,
-- except as part of quoted-strings.
headerParseList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@header@/: a header value
    -> m [T.Text]
    -- ^ __Returns:__ a t'GI.GLib.Structs.SList.SList' of
    -- list elements, as allocated strings
headerParseList :: Text -> m [Text]
headerParseList Text
header = IO [Text] -> m [Text]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Text] -> m [Text]) -> IO [Text] -> m [Text]
forall a b. (a -> b) -> a -> b
$ do
    CString
header' <- Text -> IO CString
textToCString Text
header
    Ptr (GSList CString)
result <- CString -> IO (Ptr (GSList CString))
soup_header_parse_list CString
header'
    [CString]
result' <- Ptr (GSList CString) -> IO [CString]
forall a. Ptr (GSList (Ptr a)) -> IO [Ptr a]
unpackGSList Ptr (GSList CString)
result
    [Text]
result'' <- (CString -> IO Text) -> [CString] -> IO [Text]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText [CString]
result'
    (CString -> IO ()) -> Ptr (GSList CString) -> IO ()
forall a b. (Ptr a -> IO b) -> Ptr (GSList (Ptr a)) -> IO ()
mapGSList CString -> IO ()
forall a. Ptr a -> IO ()
freeMem Ptr (GSList CString)
result
    Ptr (GSList CString) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList CString)
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
header'
    [Text] -> IO [Text]
forall (m :: * -> *) a. Monad m => a -> m a
return [Text]
result''


-- function header_g_string_append_param_quoted
-- Args: [ Arg
--           { argCName = "string"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "String" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a #GString being used to construct an HTTP header value"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a parameter name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a parameter value" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_g_string_append_param_quoted" soup_header_g_string_append_param_quoted :: 
    Ptr GLib.String.String ->               -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()

-- | Appends something like \<literal>/@name@/=\"/@value@/\"\<\/literal> to
-- /@string@/, taking care to escape any quotes or backslashes in /@value@/.
-- 
-- If /@value@/ is (non-ASCII) UTF-8, this will instead use RFC 5987
-- encoding, just like 'GI.Soup.Functions.headerGStringAppendParam'.
-- 
-- /Since: 2.30/
headerGStringAppendParamQuoted ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.String.String
    -- ^ /@string@/: a t'GI.GLib.Structs.String.String' being used to construct an HTTP header value
    -> T.Text
    -- ^ /@name@/: a parameter name
    -> T.Text
    -- ^ /@value@/: a parameter value
    -> m ()
headerGStringAppendParamQuoted :: String -> Text -> Text -> m ()
headerGStringAppendParamQuoted String
string Text
name Text
value = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
name' <- Text -> IO CString
textToCString Text
name
    CString
value' <- Text -> IO CString
textToCString Text
value
    Ptr String -> CString -> CString -> IO ()
soup_header_g_string_append_param_quoted Ptr String
string' CString
name' CString
value'
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
value'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function header_g_string_append_param
-- Args: [ Arg
--           { argCName = "string"
--           , argType =
--               TInterface Name { namespace = "GLib" , name = "String" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a #GString being used to construct an HTTP header value"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "name"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a parameter name" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "value"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a parameter value, or %NULL"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_g_string_append_param" soup_header_g_string_append_param :: 
    Ptr GLib.String.String ->               -- string : TInterface (Name {namespace = "GLib", name = "String"})
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()

-- | Appends something like \<literal>/@name@/=/@value@/\<\/literal> to /@string@/,
-- taking care to quote /@value@/ if needed, and if so, to escape any
-- quotes or backslashes in /@value@/.
-- 
-- Alternatively, if /@value@/ is a non-ASCII UTF-8 string, it will be
-- appended using RFC5987 syntax. Although in theory this is supposed
-- to work anywhere in HTTP that uses this style of parameter, in
-- reality, it can only be used portably with the Content-Disposition
-- \"filename\" parameter.
-- 
-- If /@value@/ is 'P.Nothing', this will just append /@name@/ to /@string@/.
-- 
-- /Since: 2.26/
headerGStringAppendParam ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.String.String
    -- ^ /@string@/: a t'GI.GLib.Structs.String.String' being used to construct an HTTP header value
    -> T.Text
    -- ^ /@name@/: a parameter name
    -> T.Text
    -- ^ /@value@/: a parameter value, or 'P.Nothing'
    -> m ()
headerGStringAppendParam :: String -> Text -> Text -> m ()
headerGStringAppendParam String
string Text
name Text
value = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    Ptr String
string' <- String -> IO (Ptr String)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr String
string
    CString
name' <- Text -> IO CString
textToCString Text
name
    CString
value' <- Text -> IO CString
textToCString Text
value
    Ptr String -> CString -> CString -> IO ()
soup_header_g_string_append_param Ptr String
string' CString
name' CString
value'
    String -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr String
string
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
name'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
value'
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function header_free_param_list
-- Args: [ Arg
--           { argCName = "param_list"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "a #GHashTable returned from soup_header_parse_param_list()\nor soup_header_parse_semi_param_list()"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_free_param_list" soup_header_free_param_list :: 
    Ptr (GHashTable CString CString) ->     -- param_list : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    IO ()

-- | Frees /@paramList@/.
headerFreeParamList ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Map.Map T.Text T.Text
    -- ^ /@paramList@/: a t'GI.GLib.Structs.HashTable.HashTable' returned from 'GI.Soup.Functions.headerParseParamList'
    -- or 'GI.Soup.Functions.headerParseSemiParamList'
    -> m ()
headerFreeParamList :: Map Text Text -> m ()
headerFreeParamList Map Text Text
paramList = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    let paramList' :: [(Text, Text)]
paramList' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
paramList
    [(CString, Text)]
paramList'' <- (Text -> IO CString) -> [(Text, Text)] -> IO [(CString, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO CString
textToCString [(Text, Text)]
paramList'
    [(CString, CString)]
paramList''' <- (Text -> IO CString)
-> [(CString, Text)] -> IO [(CString, CString)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO CString
textToCString [(CString, Text)]
paramList''
    let paramList'''' :: [(PtrWrapped CString, CString)]
paramList'''' = (CString -> PtrWrapped CString)
-> [(CString, CString)] -> [(PtrWrapped CString, CString)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst CString -> PtrWrapped CString
cstringPackPtr [(CString, CString)]
paramList'''
    let paramList''''' :: [(PtrWrapped CString, PtrWrapped CString)]
paramList''''' = (CString -> PtrWrapped CString)
-> [(PtrWrapped CString, CString)]
-> [(PtrWrapped CString, PtrWrapped CString)]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond CString -> PtrWrapped CString
cstringPackPtr [(PtrWrapped CString, CString)]
paramList''''
    Ptr (GHashTable CString CString)
paramList'''''' <- GHashFunc CString
-> GEqualFunc CString
-> Maybe (GDestroyNotify CString)
-> Maybe (GDestroyNotify CString)
-> [(PtrWrapped CString, PtrWrapped CString)]
-> IO (Ptr (GHashTable CString CString))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc CString
gStrHash GEqualFunc CString
gStrEqual (GDestroyNotify CString -> Maybe (GDestroyNotify CString)
forall a. a -> Maybe a
Just GDestroyNotify CString
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify CString -> Maybe (GDestroyNotify CString)
forall a. a -> Maybe a
Just GDestroyNotify CString
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped CString, PtrWrapped CString)]
paramList'''''
    Ptr (GHashTable CString CString) -> IO ()
soup_header_free_param_list Ptr (GHashTable CString CString)
paramList''''''
    Ptr (GHashTable CString CString) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString CString)
paramList''''''
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function header_contains
-- Args: [ Arg
--           { argCName = "header"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just
--                       "An HTTP header suitable for parsing with\nsoup_header_parse_list()"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "token"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a token" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_contains" soup_header_contains :: 
    CString ->                              -- header : TBasicType TUTF8
    CString ->                              -- token : TBasicType TUTF8
    IO CInt

-- | Parses /@header@/ to see if it contains the token /@token@/ (matched
-- case-insensitively). Note that this can\'t be used with lists
-- that have qvalues.
headerContains ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@header@/: An HTTP header suitable for parsing with
    -- 'GI.Soup.Functions.headerParseList'
    -> T.Text
    -- ^ /@token@/: a token
    -> m Bool
    -- ^ __Returns:__ whether or not /@header@/ contains /@token@/
headerContains :: Text -> Text -> m Bool
headerContains Text
header Text
token = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CString
header' <- Text -> IO CString
textToCString Text
header
    CString
token' <- Text -> IO CString
textToCString Text
token
    CInt
result <- CString -> CString -> IO CInt
soup_header_contains CString
header' CString
token'
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
header'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
token'
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'


-- function get_minor_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_get_minor_version" soup_get_minor_version :: 
    IO Word32

-- | Returns the minor version number of the libsoup library.
-- (e.g. in libsoup version 2.42.0 this is 42.)
-- 
-- This function is in the library, so it represents the libsoup library
-- your code is running against. Contrast with the 'GI.Soup.Constants.MINOR_VERSION'
-- macro, which represents the minor version of the libsoup headers you
-- have included when compiling your code.
-- 
-- /Since: 2.42/
getMinorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the minor version number of the libsoup library
getMinorVersion :: m Word32
getMinorVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
soup_get_minor_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function get_micro_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_get_micro_version" soup_get_micro_version :: 
    IO Word32

-- | Returns the micro version number of the libsoup library.
-- (e.g. in libsoup version 2.42.0 this is 0.)
-- 
-- This function is in the library, so it represents the libsoup library
-- your code is running against. Contrast with the 'GI.Soup.Constants.MICRO_VERSION'
-- macro, which represents the micro version of the libsoup headers you
-- have included when compiling your code.
-- 
-- /Since: 2.42/
getMicroVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the micro version number of the libsoup library
getMicroVersion :: m Word32
getMicroVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
soup_get_micro_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function get_major_version
-- Args: []
-- Lengths: []
-- returnType: Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_get_major_version" soup_get_major_version :: 
    IO Word32

-- | Returns the major version number of the libsoup library.
-- (e.g. in libsoup version 2.42.0 this is 2.)
-- 
-- This function is in the library, so it represents the libsoup library
-- your code is running against. Contrast with the 'GI.Soup.Constants.MAJOR_VERSION'
-- macro, which represents the major version of the libsoup headers you
-- have included when compiling your code.
-- 
-- /Since: 2.42/
getMajorVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    m Word32
    -- ^ __Returns:__ the major version number of the libsoup library
getMajorVersion :: m Word32
getMajorVersion  = IO Word32 -> m Word32
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Word32 -> m Word32) -> IO Word32 -> m Word32
forall a b. (a -> b) -> a -> b
$ do
    Word32
result <- IO Word32
soup_get_major_version
    Word32 -> IO Word32
forall (m :: * -> *) a. Monad m => a -> m a
return Word32
result


-- function form_request_new_from_multipart
-- Args: [ Arg
--           { argCName = "uri"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the URI to send the form data to"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "multipart"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Multipart" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a \"multipart/form-data\" #SoupMultipart"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "Message" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_request_new_from_multipart" soup_form_request_new_from_multipart :: 
    CString ->                              -- uri : TBasicType TUTF8
    Ptr Soup.Multipart.Multipart ->         -- multipart : TInterface (Name {namespace = "Soup", name = "Multipart"})
    IO (Ptr Soup.Message.Message)

-- | Creates a new @/SoupMessage/@ and sets it up to send /@multipart@/ to
-- /@uri@/ via POST.
-- 
-- To send a \<literal>\"multipart\/form-data\"\<\/literal> POST, first
-- create a t'GI.Soup.Structs.Multipart.Multipart', using 'GI.Soup.Constants.FORM_MIME_TYPE_MULTIPART' as
-- the MIME type. Then use 'GI.Soup.Structs.Multipart.multipartAppendFormString' and
-- 'GI.Soup.Structs.Multipart.multipartAppendFormFile' to add the value of each form
-- control to the multipart. (These are just convenience methods, and
-- you can use 'GI.Soup.Structs.Multipart.multipartAppendPart' if you need greater
-- control over the part headers.) Finally, call
-- 'GI.Soup.Functions.formRequestNewFromMultipart' to serialize the multipart
-- structure and create a t'GI.Soup.Objects.Message.Message'.
-- 
-- /Since: 2.26/
formRequestNewFromMultipart ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@uri@/: the URI to send the form data to
    -> Soup.Multipart.Multipart
    -- ^ /@multipart@/: a \"multipart\/form-data\" t'GI.Soup.Structs.Multipart.Multipart'
    -> m Soup.Message.Message
    -- ^ __Returns:__ the new @/SoupMessage/@
formRequestNewFromMultipart :: Text -> Multipart -> m Message
formRequestNewFromMultipart Text
uri Multipart
multipart = IO Message -> m Message
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Message -> m Message) -> IO Message -> m Message
forall a b. (a -> b) -> a -> b
$ do
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    Ptr Multipart
multipart' <- Multipart -> IO (Ptr Multipart)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Multipart
multipart
    Ptr Message
result <- CString -> Ptr Multipart -> IO (Ptr Message)
soup_form_request_new_from_multipart CString
uri' Ptr Multipart
multipart'
    Text -> Ptr Message -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"formRequestNewFromMultipart" Ptr Message
result
    Message
result' <- ((ManagedPtr Message -> Message) -> Ptr Message -> IO Message
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Message -> Message
Soup.Message.Message) Ptr Message
result
    Multipart -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Multipart
multipart
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
    Message -> IO Message
forall (m :: * -> *) a. Monad m => a -> m a
return Message
result'


-- function form_request_new_from_hash
-- Args: [ Arg
--           { argCName = "method"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the HTTP method, either \"GET\" or \"POST\""
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "uri"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the URI to send the form data to"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "form_data_set"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the data to send to @uri"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "Message" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_request_new_from_hash" soup_form_request_new_from_hash :: 
    CString ->                              -- method : TBasicType TUTF8
    CString ->                              -- uri : TBasicType TUTF8
    Ptr (GHashTable CString CString) ->     -- form_data_set : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    IO (Ptr Soup.Message.Message)

-- | Creates a new @/SoupMessage/@ and sets it up to send /@formDataSet@/ to
-- /@uri@/ via /@method@/, as with @/soup_form_request_new()/@.
formRequestNewFromHash ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@method@/: the HTTP method, either \"GET\" or \"POST\"
    -> T.Text
    -- ^ /@uri@/: the URI to send the form data to
    -> Map.Map T.Text T.Text
    -- ^ /@formDataSet@/: the data to send to /@uri@/
    -> m Soup.Message.Message
    -- ^ __Returns:__ the new @/SoupMessage/@
formRequestNewFromHash :: Text -> Text -> Map Text Text -> m Message
formRequestNewFromHash Text
method Text
uri Map Text Text
formDataSet = IO Message -> m Message
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Message -> m Message) -> IO Message -> m Message
forall a b. (a -> b) -> a -> b
$ do
    CString
method' <- Text -> IO CString
textToCString Text
method
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    let formDataSet' :: [(Text, Text)]
formDataSet' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
formDataSet
    [(CString, Text)]
formDataSet'' <- (Text -> IO CString) -> [(Text, Text)] -> IO [(CString, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO CString
textToCString [(Text, Text)]
formDataSet'
    [(CString, CString)]
formDataSet''' <- (Text -> IO CString)
-> [(CString, Text)] -> IO [(CString, CString)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO CString
textToCString [(CString, Text)]
formDataSet''
    let formDataSet'''' :: [(PtrWrapped CString, CString)]
formDataSet'''' = (CString -> PtrWrapped CString)
-> [(CString, CString)] -> [(PtrWrapped CString, CString)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst CString -> PtrWrapped CString
cstringPackPtr [(CString, CString)]
formDataSet'''
    let formDataSet''''' :: [(PtrWrapped CString, PtrWrapped CString)]
formDataSet''''' = (CString -> PtrWrapped CString)
-> [(PtrWrapped CString, CString)]
-> [(PtrWrapped CString, PtrWrapped CString)]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond CString -> PtrWrapped CString
cstringPackPtr [(PtrWrapped CString, CString)]
formDataSet''''
    Ptr (GHashTable CString CString)
formDataSet'''''' <- GHashFunc CString
-> GEqualFunc CString
-> Maybe (GDestroyNotify CString)
-> Maybe (GDestroyNotify CString)
-> [(PtrWrapped CString, PtrWrapped CString)]
-> IO (Ptr (GHashTable CString CString))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc CString
gStrHash GEqualFunc CString
gStrEqual (GDestroyNotify CString -> Maybe (GDestroyNotify CString)
forall a. a -> Maybe a
Just GDestroyNotify CString
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify CString -> Maybe (GDestroyNotify CString)
forall a. a -> Maybe a
Just GDestroyNotify CString
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped CString, PtrWrapped CString)]
formDataSet'''''
    Ptr Message
result <- CString
-> CString -> Ptr (GHashTable CString CString) -> IO (Ptr Message)
soup_form_request_new_from_hash CString
method' CString
uri' Ptr (GHashTable CString CString)
formDataSet''''''
    Text -> Ptr Message -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"formRequestNewFromHash" Ptr Message
result
    Message
result' <- ((ManagedPtr Message -> Message) -> Ptr Message -> IO Message
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Message -> Message
Soup.Message.Message) Ptr Message
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
method'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
    Ptr (GHashTable CString CString) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString CString)
formDataSet''''''
    Message -> IO Message
forall (m :: * -> *) a. Monad m => a -> m a
return Message
result'


-- function form_request_new_from_datalist
-- Args: [ Arg
--           { argCName = "method"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the HTTP method, either \"GET\" or \"POST\""
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "uri"
--           , argType = TBasicType TUTF8
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the URI to send the form data to"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "form_data_set"
--           , argType = TInterface Name { namespace = "GLib" , name = "Data" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the data to send to @uri"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TInterface Name { namespace = "Soup" , name = "Message" })
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_request_new_from_datalist" soup_form_request_new_from_datalist :: 
    CString ->                              -- method : TBasicType TUTF8
    CString ->                              -- uri : TBasicType TUTF8
    Ptr GLib.Data.Data ->                   -- form_data_set : TInterface (Name {namespace = "GLib", name = "Data"})
    IO (Ptr Soup.Message.Message)

-- | Creates a new @/SoupMessage/@ and sets it up to send /@formDataSet@/ to
-- /@uri@/ via /@method@/, as with @/soup_form_request_new()/@.
formRequestNewFromDatalist ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    T.Text
    -- ^ /@method@/: the HTTP method, either \"GET\" or \"POST\"
    -> T.Text
    -- ^ /@uri@/: the URI to send the form data to
    -> GLib.Data.Data
    -- ^ /@formDataSet@/: the data to send to /@uri@/
    -> m Soup.Message.Message
    -- ^ __Returns:__ the new @/SoupMessage/@
formRequestNewFromDatalist :: Text -> Text -> Data -> m Message
formRequestNewFromDatalist Text
method Text
uri Data
formDataSet = IO Message -> m Message
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Message -> m Message) -> IO Message -> m Message
forall a b. (a -> b) -> a -> b
$ do
    CString
method' <- Text -> IO CString
textToCString Text
method
    CString
uri' <- Text -> IO CString
textToCString Text
uri
    Ptr Data
formDataSet' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
formDataSet
    Ptr Message
result <- CString -> CString -> Ptr Data -> IO (Ptr Message)
soup_form_request_new_from_datalist CString
method' CString
uri' Ptr Data
formDataSet'
    Text -> Ptr Message -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"formRequestNewFromDatalist" Ptr Message
result
    Message
result' <- ((ManagedPtr Message -> Message) -> Ptr Message -> IO Message
forall a b.
(HasCallStack, GObject a, GObject b) =>
(ManagedPtr a -> a) -> Ptr b -> IO a
wrapObject ManagedPtr Message -> Message
Soup.Message.Message) Ptr Message
result
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
formDataSet
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
method'
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
uri'
    Message -> IO Message
forall (m :: * -> *) a. Monad m => a -> m a
return Message
result'


-- function form_encode_hash
-- Args: [ Arg
--           { argCName = "form_data_set"
--           , argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8)
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a hash table containing\nname/value pairs (as strings)"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_encode_hash" soup_form_encode_hash :: 
    Ptr (GHashTable CString CString) ->     -- form_data_set : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
    IO CString

-- | Encodes /@formDataSet@/ into a value of type
-- \"application\/x-www-form-urlencoded\", as defined in the HTML 4.01
-- spec.
-- 
-- Note that the HTML spec states that \"The control names\/values are
-- listed in the order they appear in the document.\" Since this method
-- takes a hash table, it cannot enforce that; if you care about the
-- ordering of the form fields, use 'GI.Soup.Functions.formEncodeDatalist'.
formEncodeHash ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Map.Map T.Text T.Text
    -- ^ /@formDataSet@/: a hash table containing
    -- name\/value pairs (as strings)
    -> m T.Text
    -- ^ __Returns:__ the encoded form
formEncodeHash :: Map Text Text -> m Text
formEncodeHash Map Text Text
formDataSet = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    let formDataSet' :: [(Text, Text)]
formDataSet' = Map Text Text -> [(Text, Text)]
forall k a. Map k a -> [(k, a)]
Map.toList Map Text Text
formDataSet
    [(CString, Text)]
formDataSet'' <- (Text -> IO CString) -> [(Text, Text)] -> IO [(CString, Text)]
forall (f :: * -> *) a c b.
Applicative f =>
(a -> f c) -> [(a, b)] -> f [(c, b)]
mapFirstA Text -> IO CString
textToCString [(Text, Text)]
formDataSet'
    [(CString, CString)]
formDataSet''' <- (Text -> IO CString)
-> [(CString, Text)] -> IO [(CString, CString)]
forall (f :: * -> *) b c a.
Applicative f =>
(b -> f c) -> [(a, b)] -> f [(a, c)]
mapSecondA Text -> IO CString
textToCString [(CString, Text)]
formDataSet''
    let formDataSet'''' :: [(PtrWrapped CString, CString)]
formDataSet'''' = (CString -> PtrWrapped CString)
-> [(CString, CString)] -> [(PtrWrapped CString, CString)]
forall a c b. (a -> c) -> [(a, b)] -> [(c, b)]
mapFirst CString -> PtrWrapped CString
cstringPackPtr [(CString, CString)]
formDataSet'''
    let formDataSet''''' :: [(PtrWrapped CString, PtrWrapped CString)]
formDataSet''''' = (CString -> PtrWrapped CString)
-> [(PtrWrapped CString, CString)]
-> [(PtrWrapped CString, PtrWrapped CString)]
forall b c a. (b -> c) -> [(a, b)] -> [(a, c)]
mapSecond CString -> PtrWrapped CString
cstringPackPtr [(PtrWrapped CString, CString)]
formDataSet''''
    Ptr (GHashTable CString CString)
formDataSet'''''' <- GHashFunc CString
-> GEqualFunc CString
-> Maybe (GDestroyNotify CString)
-> Maybe (GDestroyNotify CString)
-> [(PtrWrapped CString, PtrWrapped CString)]
-> IO (Ptr (GHashTable CString CString))
forall a b.
GHashFunc a
-> GEqualFunc a
-> Maybe (GDestroyNotify a)
-> Maybe (GDestroyNotify b)
-> [(PtrWrapped a, PtrWrapped b)]
-> IO (Ptr (GHashTable a b))
packGHashTable GHashFunc CString
gStrHash GEqualFunc CString
gStrEqual (GDestroyNotify CString -> Maybe (GDestroyNotify CString)
forall a. a -> Maybe a
Just GDestroyNotify CString
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) (GDestroyNotify CString -> Maybe (GDestroyNotify CString)
forall a. a -> Maybe a
Just GDestroyNotify CString
forall a. FunPtr (Ptr a -> IO ())
ptr_to_g_free) [(PtrWrapped CString, PtrWrapped CString)]
formDataSet'''''
    CString
result <- Ptr (GHashTable CString CString) -> IO CString
soup_form_encode_hash Ptr (GHashTable CString CString)
formDataSet''''''
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"formEncodeHash" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Ptr (GHashTable CString CString) -> IO ()
forall a b. Ptr (GHashTable a b) -> IO ()
unrefGHashTable Ptr (GHashTable CString CString)
formDataSet''''''
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function form_encode_datalist
-- Args: [ Arg
--           { argCName = "form_data_set"
--           , argType = TInterface Name { namespace = "GLib" , name = "Data" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a datalist containing name/value pairs"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_encode_datalist" soup_form_encode_datalist :: 
    Ptr GLib.Data.Data ->                   -- form_data_set : TInterface (Name {namespace = "GLib", name = "Data"})
    IO CString

-- | Encodes /@formDataSet@/ into a value of type
-- \"application\/x-www-form-urlencoded\", as defined in the HTML 4.01
-- spec. Unlike 'GI.Soup.Functions.formEncodeHash', this preserves the ordering
-- of the form elements, which may be required in some situations.
formEncodeDatalist ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    GLib.Data.Data
    -- ^ /@formDataSet@/: a datalist containing name\/value pairs
    -> m T.Text
    -- ^ __Returns:__ the encoded form
formEncodeDatalist :: Data -> m Text
formEncodeDatalist Data
formDataSet = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    Ptr Data
formDataSet' <- Data -> IO (Ptr Data)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr Data
formDataSet
    CString
result <- Ptr Data -> IO CString
soup_form_encode_datalist Ptr Data
formDataSet'
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"formEncodeDatalist" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    Data -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr Data
formDataSet
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function form_decode_multipart
-- XXX Could not generate function form_decode_multipart

-- Not implemented: Hash table argument with transfer = Container? result'

-- function form_decode
-- XXX Could not generate function form_decode

-- Not implemented: Hash table argument with transfer = Container? result

-- function cookies_to_response
-- Args: [ Arg
--           { argCName = "cookies"
--           , argType =
--               TGSList (TInterface Name { namespace = "Soup" , name = "Cookie" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSList of #SoupCookie"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupMessage" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_to_response" soup_cookies_to_response :: 
    Ptr (GSList (Ptr Soup.Cookie.Cookie)) -> -- cookies : TGSList (TInterface (Name {namespace = "Soup", name = "Cookie"}))
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO ()

-- | Appends a \"Set-Cookie\" response header to /@msg@/ for each cookie in
-- /@cookies@/. (This is in addition to any other \"Set-Cookie\" headers
-- /@msg@/ may already have.)
-- 
-- /Since: 2.24/
cookiesToResponse ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    [Soup.Cookie.Cookie]
    -- ^ /@cookies@/: a t'GI.GLib.Structs.SList.SList' of t'GI.Soup.Structs.Cookie.Cookie'
    -> a
    -- ^ /@msg@/: a t'GI.Soup.Objects.Message.Message'
    -> m ()
cookiesToResponse :: [Cookie] -> a -> m ()
cookiesToResponse [Cookie]
cookies a
msg = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    [Ptr Cookie]
cookies' <- (Cookie -> IO (Ptr Cookie)) -> [Cookie] -> IO [Ptr Cookie]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Cookie -> IO (Ptr Cookie)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [Cookie]
cookies
    Ptr (GSList (Ptr Cookie))
cookies'' <- [Ptr Cookie] -> IO (Ptr (GSList (Ptr Cookie)))
forall a. [Ptr a] -> IO (Ptr (GSList (Ptr a)))
packGSList [Ptr Cookie]
cookies'
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    Ptr (GSList (Ptr Cookie)) -> Ptr Message -> IO ()
soup_cookies_to_response Ptr (GSList (Ptr Cookie))
cookies'' Ptr Message
msg'
    (Cookie -> IO ()) -> [Cookie] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Cookie -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [Cookie]
cookies
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    Ptr (GSList (Ptr Cookie)) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList (Ptr Cookie))
cookies''
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function cookies_to_request
-- Args: [ Arg
--           { argCName = "cookies"
--           , argType =
--               TGSList (TInterface Name { namespace = "Soup" , name = "Cookie" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSList of #SoupCookie"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #SoupMessage" , sinceVersion = Nothing }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_to_request" soup_cookies_to_request :: 
    Ptr (GSList (Ptr Soup.Cookie.Cookie)) -> -- cookies : TGSList (TInterface (Name {namespace = "Soup", name = "Cookie"}))
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO ()

-- | Adds the name and value of each cookie in /@cookies@/ to /@msg@/\'s
-- \"Cookie\" request. (If /@msg@/ already has a \"Cookie\" request header,
-- these cookies will be appended to the cookies already present. Be
-- careful that you do not append the same cookies twice, eg, when
-- requeuing a message.)
-- 
-- /Since: 2.24/
cookiesToRequest ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    [Soup.Cookie.Cookie]
    -- ^ /@cookies@/: a t'GI.GLib.Structs.SList.SList' of t'GI.Soup.Structs.Cookie.Cookie'
    -> a
    -- ^ /@msg@/: a t'GI.Soup.Objects.Message.Message'
    -> m ()
cookiesToRequest :: [Cookie] -> a -> m ()
cookiesToRequest [Cookie]
cookies a
msg = IO () -> m ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> m ()) -> IO () -> m ()
forall a b. (a -> b) -> a -> b
$ do
    [Ptr Cookie]
cookies' <- (Cookie -> IO (Ptr Cookie)) -> [Cookie] -> IO [Ptr Cookie]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Cookie -> IO (Ptr Cookie)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [Cookie]
cookies
    Ptr (GSList (Ptr Cookie))
cookies'' <- [Ptr Cookie] -> IO (Ptr (GSList (Ptr Cookie)))
forall a. [Ptr a] -> IO (Ptr (GSList (Ptr a)))
packGSList [Ptr Cookie]
cookies'
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    Ptr (GSList (Ptr Cookie)) -> Ptr Message -> IO ()
soup_cookies_to_request Ptr (GSList (Ptr Cookie))
cookies'' Ptr Message
msg'
    (Cookie -> IO ()) -> [Cookie] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Cookie -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [Cookie]
cookies
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    Ptr (GSList (Ptr Cookie)) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList (Ptr Cookie))
cookies''
    () -> IO ()
forall (m :: * -> *) a. Monad m => a -> m a
return ()


-- function cookies_to_cookie_header
-- Args: [ Arg
--           { argCName = "cookies"
--           , argType =
--               TGSList (TInterface Name { namespace = "Soup" , name = "Cookie" })
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "a #GSList of #SoupCookie"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_to_cookie_header" soup_cookies_to_cookie_header :: 
    Ptr (GSList (Ptr Soup.Cookie.Cookie)) -> -- cookies : TGSList (TInterface (Name {namespace = "Soup", name = "Cookie"}))
    IO CString

-- | Serializes a t'GI.GLib.Structs.SList.SList' of t'GI.Soup.Structs.Cookie.Cookie' into a string suitable for
-- setting as the value of the \"Cookie\" header.
-- 
-- /Since: 2.24/
cookiesToCookieHeader ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    [Soup.Cookie.Cookie]
    -- ^ /@cookies@/: a t'GI.GLib.Structs.SList.SList' of t'GI.Soup.Structs.Cookie.Cookie'
    -> m T.Text
    -- ^ __Returns:__ the serialization of /@cookies@/
cookiesToCookieHeader :: [Cookie] -> m Text
cookiesToCookieHeader [Cookie]
cookies = IO Text -> m Text
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Text -> m Text) -> IO Text -> m Text
forall a b. (a -> b) -> a -> b
$ do
    [Ptr Cookie]
cookies' <- (Cookie -> IO (Ptr Cookie)) -> [Cookie] -> IO [Ptr Cookie]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM Cookie -> IO (Ptr Cookie)
forall a. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr a)
unsafeManagedPtrGetPtr [Cookie]
cookies
    Ptr (GSList (Ptr Cookie))
cookies'' <- [Ptr Cookie] -> IO (Ptr (GSList (Ptr Cookie)))
forall a. [Ptr a] -> IO (Ptr (GSList (Ptr a)))
packGSList [Ptr Cookie]
cookies'
    CString
result <- Ptr (GSList (Ptr Cookie)) -> IO CString
soup_cookies_to_cookie_header Ptr (GSList (Ptr Cookie))
cookies''
    Text -> CString -> IO ()
forall a. HasCallStack => Text -> Ptr a -> IO ()
checkUnexpectedReturnNULL Text
"cookiesToCookieHeader" CString
result
    Text
result' <- HasCallStack => CString -> IO Text
CString -> IO Text
cstringToText CString
result
    CString -> IO ()
forall a. Ptr a -> IO ()
freeMem CString
result
    (Cookie -> IO ()) -> [Cookie] -> IO ()
forall (t :: * -> *) (m :: * -> *) a b.
(Foldable t, Monad m) =>
(a -> m b) -> t a -> m ()
mapM_ Cookie -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr [Cookie]
cookies
    Ptr (GSList (Ptr Cookie)) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList (Ptr Cookie))
cookies''
    Text -> IO Text
forall (m :: * -> *) a. Monad m => a -> m a
return Text
result'


-- function cookies_from_response
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a #SoupMessage containing a \"Set-Cookie\" response header"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGSList
--                  (TInterface Name { namespace = "Soup" , name = "Cookie" }))
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_from_response" soup_cookies_from_response :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO (Ptr (GSList (Ptr Soup.Cookie.Cookie)))

-- | Parses /@msg@/\'s Set-Cookie response headers and returns a t'GI.GLib.Structs.SList.SList' of
-- t'GI.Soup.Structs.Cookie.Cookie's. Cookies that do not specify \"path\" or
-- \"domain\" attributes will have their values defaulted from /@msg@/.
-- 
-- /Since: 2.24/
cookiesFromResponse ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: a t'GI.Soup.Objects.Message.Message' containing a \"Set-Cookie\" response header
    -> m [Soup.Cookie.Cookie]
    -- ^ __Returns:__ a t'GI.GLib.Structs.SList.SList'
    -- of t'GI.Soup.Structs.Cookie.Cookie's, which can be freed with
    -- @/soup_cookies_free()/@.
cookiesFromResponse :: a -> m [Cookie]
cookiesFromResponse a
msg = IO [Cookie] -> m [Cookie]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Cookie] -> m [Cookie]) -> IO [Cookie] -> m [Cookie]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    Ptr (GSList (Ptr Cookie))
result <- Ptr Message -> IO (Ptr (GSList (Ptr Cookie)))
soup_cookies_from_response Ptr Message
msg'
    [Ptr Cookie]
result' <- Ptr (GSList (Ptr Cookie)) -> IO [Ptr Cookie]
forall a. Ptr (GSList (Ptr a)) -> IO [Ptr a]
unpackGSList Ptr (GSList (Ptr Cookie))
result
    [Cookie]
result'' <- (Ptr Cookie -> IO Cookie) -> [Ptr Cookie] -> IO [Cookie]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr Cookie -> Cookie) -> Ptr Cookie -> IO Cookie
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Cookie -> Cookie
Soup.Cookie.Cookie) [Ptr Cookie]
result'
    Ptr (GSList (Ptr Cookie)) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList (Ptr Cookie))
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    [Cookie] -> IO [Cookie]
forall (m :: * -> *) a. Monad m => a -> m a
return [Cookie]
result''


-- function cookies_from_request
-- Args: [ Arg
--           { argCName = "msg"
--           , argType =
--               TInterface Name { namespace = "Soup" , name = "Message" }
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText =
--                     Just "a #SoupMessage containing a \"Cookie\" request header"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just
--               (TGSList
--                  (TInterface Name { namespace = "Soup" , name = "Cookie" }))
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_from_request" soup_cookies_from_request :: 
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO (Ptr (GSList (Ptr Soup.Cookie.Cookie)))

-- | Parses /@msg@/\'s Cookie request header and returns a t'GI.GLib.Structs.SList.SList' of
-- t'GI.Soup.Structs.Cookie.Cookie's. As the \"Cookie\" header, unlike \"Set-Cookie\",
-- only contains cookie names and values, none of the other
-- t'GI.Soup.Structs.Cookie.Cookie' fields will be filled in. (Thus, you can\'t generally
-- pass a cookie returned from this method directly to
-- 'GI.Soup.Functions.cookiesToResponse'.)
-- 
-- /Since: 2.24/
cookiesFromRequest ::
    (B.CallStack.HasCallStack, MonadIO m, Soup.Message.IsMessage a) =>
    a
    -- ^ /@msg@/: a t'GI.Soup.Objects.Message.Message' containing a \"Cookie\" request header
    -> m [Soup.Cookie.Cookie]
    -- ^ __Returns:__ a t'GI.GLib.Structs.SList.SList'
    -- of t'GI.Soup.Structs.Cookie.Cookie's, which can be freed with
    -- @/soup_cookies_free()/@.
cookiesFromRequest :: a -> m [Cookie]
cookiesFromRequest a
msg = IO [Cookie] -> m [Cookie]
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO [Cookie] -> m [Cookie]) -> IO [Cookie] -> m [Cookie]
forall a b. (a -> b) -> a -> b
$ do
    Ptr Message
msg' <- a -> IO (Ptr Message)
forall a b. (HasCallStack, ManagedPtrNewtype a) => a -> IO (Ptr b)
unsafeManagedPtrCastPtr a
msg
    Ptr (GSList (Ptr Cookie))
result <- Ptr Message -> IO (Ptr (GSList (Ptr Cookie)))
soup_cookies_from_request Ptr Message
msg'
    [Ptr Cookie]
result' <- Ptr (GSList (Ptr Cookie)) -> IO [Ptr Cookie]
forall a. Ptr (GSList (Ptr a)) -> IO [Ptr a]
unpackGSList Ptr (GSList (Ptr Cookie))
result
    [Cookie]
result'' <- (Ptr Cookie -> IO Cookie) -> [Ptr Cookie] -> IO [Cookie]
forall (t :: * -> *) (m :: * -> *) a b.
(Traversable t, Monad m) =>
(a -> m b) -> t a -> m (t b)
mapM ((ManagedPtr Cookie -> Cookie) -> Ptr Cookie -> IO Cookie
forall a.
(HasCallStack, GBoxed a) =>
(ManagedPtr a -> a) -> Ptr a -> IO a
wrapBoxed ManagedPtr Cookie -> Cookie
Soup.Cookie.Cookie) [Ptr Cookie]
result'
    Ptr (GSList (Ptr Cookie)) -> IO ()
forall a. Ptr (GSList a) -> IO ()
g_slist_free Ptr (GSList (Ptr Cookie))
result
    a -> IO ()
forall a. ManagedPtrNewtype a => a -> IO ()
touchManagedPtr a
msg
    [Cookie] -> IO [Cookie]
forall (m :: * -> *) a. Monad m => a -> m a
return [Cookie]
result''


-- function check_version
-- Args: [ Arg
--           { argCName = "major"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the major version to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "minor"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the minor version to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       , Arg
--           { argCName = "micro"
--           , argType = TBasicType TUInt
--           , direction = DirectionIn
--           , mayBeNull = False
--           , argDoc =
--               Documentation
--                 { rawDocText = Just "the micro version to check"
--                 , sinceVersion = Nothing
--                 }
--           , argScope = ScopeTypeInvalid
--           , argClosure = -1
--           , argDestroy = -1
--           , argCallerAllocates = False
--           , transfer = TransferNothing
--           }
--       ]
-- Lengths: []
-- returnType: Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_check_version" soup_check_version :: 
    Word32 ->                               -- major : TBasicType TUInt
    Word32 ->                               -- minor : TBasicType TUInt
    Word32 ->                               -- micro : TBasicType TUInt
    IO CInt

-- | Like SOUP_CHECK_VERSION, but the check for soup_check_version is
-- at runtime instead of compile time. This is useful for compiling
-- against older versions of libsoup, but using features from newer
-- versions.
-- 
-- /Since: 2.42/
checkVersion ::
    (B.CallStack.HasCallStack, MonadIO m) =>
    Word32
    -- ^ /@major@/: the major version to check
    -> Word32
    -- ^ /@minor@/: the minor version to check
    -> Word32
    -- ^ /@micro@/: the micro version to check
    -> m Bool
    -- ^ __Returns:__ 'P.True' if the version of the libsoup currently loaded
    -- is the same as or newer than the passed-in version.
checkVersion :: Word32 -> Word32 -> Word32 -> m Bool
checkVersion Word32
major Word32
minor Word32
micro = IO Bool -> m Bool
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO Bool -> m Bool) -> IO Bool -> m Bool
forall a b. (a -> b) -> a -> b
$ do
    CInt
result <- Word32 -> Word32 -> Word32 -> IO CInt
soup_check_version Word32
major Word32
minor Word32
micro
    let result' :: Bool
result' = (CInt -> CInt -> Bool
forall a. Eq a => a -> a -> Bool
/= CInt
0) CInt
result
    Bool -> IO Bool
forall (m :: * -> *) a. Monad m => a -> m a
return Bool
result'