{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (garetxe@gmail.com)
-}

module GI.Soup.Functions
    ( 

 -- * Methods
-- ** cookieParse
    cookieParse                             ,


-- ** cookiesFromRequest
    cookiesFromRequest                      ,


-- ** cookiesFromResponse
    cookiesFromResponse                     ,


-- ** cookiesToCookieHeader
    cookiesToCookieHeader                   ,


-- ** cookiesToRequest
    cookiesToRequest                        ,


-- ** cookiesToResponse
    cookiesToResponse                       ,


-- ** formDecode
    formDecode                              ,


-- ** formDecodeMultipart
    formDecodeMultipart                     ,


-- ** formEncodeDatalist
    formEncodeDatalist                      ,


-- ** formEncodeHash
    formEncodeHash                          ,


-- ** formRequestNewFromDatalist
    formRequestNewFromDatalist              ,


-- ** formRequestNewFromHash
    formRequestNewFromHash                  ,


-- ** formRequestNewFromMultipart
    formRequestNewFromMultipart             ,


-- ** headerContains
    headerContains                          ,


-- ** headerFreeParamList
    headerFreeParamList                     ,


-- ** headerGStringAppendParam
    headerGStringAppendParam                ,


-- ** headerGStringAppendParamQuoted
    headerGStringAppendParamQuoted          ,


-- ** headerParseList
    headerParseList                         ,


-- ** headerParseParamList
    headerParseParamList                    ,


-- ** headerParseQualityList
    headerParseQualityList                  ,


-- ** headerParseSemiParamList
    headerParseSemiParamList                ,


-- ** headersParse
    headersParse                            ,


-- ** headersParseRequest
    headersParseRequest                     ,


-- ** headersParseResponse
    headersParseResponse                    ,


-- ** headersParseStatusLine
    headersParseStatusLine                  ,


-- ** httpErrorQuark
    httpErrorQuark                          ,


-- ** messageHeadersIterInit
    messageHeadersIterInit                  ,


-- ** requestErrorQuark
    requestErrorQuark                       ,


-- ** requesterErrorQuark
    requesterErrorQuark                     ,


-- ** statusGetPhrase
    statusGetPhrase                         ,


-- ** statusProxify
    statusProxify                           ,


-- ** strCaseEqual
    strCaseEqual                            ,


-- ** strCaseHash
    strCaseHash                             ,


-- ** tldDomainIsPublicSuffix
    tldDomainIsPublicSuffix                 ,


-- ** tldErrorQuark
    tldErrorQuark                           ,


-- ** tldGetBaseDomain
    tldGetBaseDomain                        ,


-- ** uriDecode
    uriDecode                               ,


-- ** uriEncode
    uriEncode                               ,


-- ** uriNormalize
    uriNormalize                            ,


-- ** valueArrayNew
    valueArrayNew                           ,


-- ** websocketClientPrepareHandshake
    websocketClientPrepareHandshake         ,


-- ** websocketClientVerifyHandshake
    websocketClientVerifyHandshake          ,


-- ** websocketErrorGetQuark
    websocketErrorGetQuark                  ,


-- ** websocketServerCheckHandshake
    websocketServerCheckHandshake           ,


-- ** websocketServerProcessHandshake
    websocketServerProcessHandshake         ,


-- ** xmlrpcBuildMethodCall
    xmlrpcBuildMethodCall                   ,


-- ** xmlrpcBuildMethodResponse
    xmlrpcBuildMethodResponse               ,


-- ** xmlrpcBuildRequest
    xmlrpcBuildRequest                      ,


-- ** xmlrpcBuildResponse
    xmlrpcBuildResponse                     ,


-- ** xmlrpcErrorQuark
    xmlrpcErrorQuark                        ,


-- ** xmlrpcFaultQuark
    xmlrpcFaultQuark                        ,


-- ** xmlrpcMessageNew
    xmlrpcMessageNew                        ,


-- ** xmlrpcMessageSetResponse
    xmlrpcMessageSetResponse                ,


-- ** xmlrpcParseMethodCall
    xmlrpcParseMethodCall                   ,


-- ** xmlrpcParseMethodResponse
    xmlrpcParseMethodResponse               ,


-- ** xmlrpcParseRequest
    xmlrpcParseRequest                      ,


-- ** xmlrpcParseResponse
    xmlrpcParseResponse                     ,


-- ** xmlrpcVariantGetDatetime
    xmlrpcVariantGetDatetime                ,


-- ** xmlrpcVariantNewDatetime
    xmlrpcVariantNewDatetime                ,




    ) where

import Prelude ()
import Data.GI.Base.ShortPrelude

import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map

import GI.Soup.Types
import GI.Soup.Callbacks
import qualified GI.GLib as GLib
import qualified GI.GObject as GObject

-- function soup_xmlrpc_variant_new_datetime
-- Args : [Arg {argName = "date", argType = TInterface "Soup" "Date", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "date", argType = TInterface "Soup" "Date", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TVariant
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_variant_new_datetime" soup_xmlrpc_variant_new_datetime :: 
    Ptr Date ->                             -- date : TInterface "Soup" "Date"
    IO (Ptr GVariant)


xmlrpcVariantNewDatetime ::
    (MonadIO m) =>
    Date ->                                 -- date
    m GVariant
xmlrpcVariantNewDatetime date = liftIO $ do
    let date' = unsafeManagedPtrGetPtr date
    result <- soup_xmlrpc_variant_new_datetime date'
    checkUnexpectedReturnNULL "soup_xmlrpc_variant_new_datetime" result
    result' <- wrapGVariantPtr result
    touchManagedPtr date
    return result'


-- function soup_xmlrpc_variant_get_datetime
-- Args : [Arg {argName = "variant", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "variant", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "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 Date)


xmlrpcVariantGetDatetime ::
    (MonadIO m) =>
    GVariant ->                             -- variant
    m Date
xmlrpcVariantGetDatetime variant = liftIO $ do
    let variant' = unsafeManagedPtrGetPtr variant
    onException (do
        result <- propagateGError $ soup_xmlrpc_variant_get_datetime variant'
        checkUnexpectedReturnNULL "soup_xmlrpc_variant_get_datetime" result
        result' <- (wrapBoxed Date) result
        return result'
     ) (do
        return ()
     )


-- function soup_xmlrpc_parse_response
-- Args : [Arg {argName = "method_response", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "signature", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "method_response", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "signature", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 TInt32
    CString ->                              -- signature : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO (Ptr GVariant)


xmlrpcParseResponse ::
    (MonadIO m) =>
    T.Text ->                               -- method_response
    Int32 ->                                -- length
    Maybe (T.Text) ->                       -- signature
    m GVariant
xmlrpcParseResponse method_response length_ signature = liftIO $ do
    method_response' <- textToCString method_response
    maybeSignature <- case signature of
        Nothing -> return nullPtr
        Just jSignature -> do
            jSignature' <- textToCString jSignature
            return jSignature'
    onException (do
        result <- propagateGError $ soup_xmlrpc_parse_response method_response' length_ maybeSignature
        checkUnexpectedReturnNULL "soup_xmlrpc_parse_response" result
        result' <- wrapGVariantPtr result
        freeMem method_response'
        freeMem maybeSignature
        return result'
     ) (do
        freeMem method_response'
        freeMem maybeSignature
     )


-- function soup_xmlrpc_parse_request
-- Args : [Arg {argName = "method_call", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TInterface "Soup" "XMLRPCParams", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "method_call", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 TInt32
    Ptr (Ptr XMLRPCParams) ->               -- params : TInterface "Soup" "XMLRPCParams"
    Ptr (Ptr GError) ->                     -- error
    IO CString


xmlrpcParseRequest ::
    (MonadIO m) =>
    T.Text ->                               -- method_call
    Int32 ->                                -- length
    m (T.Text,XMLRPCParams)
xmlrpcParseRequest method_call length_ = liftIO $ do
    method_call' <- textToCString method_call
    params <- allocMem :: IO (Ptr (Ptr XMLRPCParams))
    onException (do
        result <- propagateGError $ soup_xmlrpc_parse_request method_call' length_ params
        checkUnexpectedReturnNULL "soup_xmlrpc_parse_request" result
        result' <- cstringToText result
        freeMem result
        params' <- peek params
        -- XXX Wrapping a foreign struct/union with no known destructor, leak?
        params'' <- (\x -> XMLRPCParams <$> newForeignPtr_ x) params'
        freeMem method_call'
        freeMem params
        return (result', params'')
     ) (do
        freeMem method_call'
        freeMem params
     )


-- function soup_xmlrpc_parse_method_response
-- Args : [Arg {argName = "method_response", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TInterface "GObject" "Value", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "method_response", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 TInt32
    Ptr GValue ->                           -- value : TInterface "GObject" "Value"
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{-# DEPRECATED xmlrpcParseMethodResponse ["Use soup_xmlrpc_parse_response() instead."]#-}
xmlrpcParseMethodResponse ::
    (MonadIO m) =>
    T.Text ->                               -- method_response
    Int32 ->                                -- length
    m (GValue)
xmlrpcParseMethodResponse method_response length_ = liftIO $ do
    method_response' <- textToCString method_response
    value <- callocBoxedBytes 24 :: IO (Ptr GValue)
    onException (do
        _ <- propagateGError $ soup_xmlrpc_parse_method_response method_response' length_ value
        value' <- (wrapBoxed GValue) value
        freeMem method_response'
        return value'
     ) (do
        freeMem method_response'
        freeMem value
     )


-- function soup_xmlrpc_parse_method_call
-- Args : [Arg {argName = "method_call", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "method_name", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "params", argType = TInterface "GObject" "ValueArray", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "method_call", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "length", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 TInt32
    Ptr CString ->                          -- method_name : TBasicType TUTF8
    Ptr GObject.ValueArray ->               -- params : TInterface "GObject" "ValueArray"
    IO CInt

{-# DEPRECATED xmlrpcParseMethodCall ["Use soup_xmlrpc_parse_request_full() instead."]#-}
xmlrpcParseMethodCall ::
    (MonadIO m) =>
    T.Text ->                               -- method_call
    Int32 ->                                -- length
    m (Bool,T.Text,GObject.ValueArray)
xmlrpcParseMethodCall method_call length_ = liftIO $ do
    method_call' <- textToCString method_call
    method_name <- allocMem :: IO (Ptr CString)
    params <- callocBoxedBytes 24 :: IO (Ptr GObject.ValueArray)
    result <- soup_xmlrpc_parse_method_call method_call' length_ method_name params
    let result' = (/= 0) result
    method_name' <- peek method_name
    method_name'' <- cstringToText method_name'
    freeMem method_name'
    params' <- (wrapBoxed GObject.ValueArray) params
    freeMem method_call'
    freeMem method_name
    return (result', method_name'', params')


-- function soup_xmlrpc_message_set_response
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "soup_xmlrpc_message_set_response" soup_xmlrpc_message_set_response :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    Ptr GVariant ->                         -- value : TVariant
    Ptr (Ptr GError) ->                     -- error
    IO CInt


xmlrpcMessageSetResponse ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    GVariant ->                             -- value
    m ()
xmlrpcMessageSetResponse msg value = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    let value' = unsafeManagedPtrGetPtr value
    onException (do
        _ <- propagateGError $ soup_xmlrpc_message_set_response msg' value'
        touchManagedPtr msg
        return ()
     ) (do
        return ()
     )


-- function soup_xmlrpc_message_new
-- Args : [Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "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 Message)


xmlrpcMessageNew ::
    (MonadIO m) =>
    T.Text ->                               -- uri
    T.Text ->                               -- method_name
    GVariant ->                             -- params
    m Message
xmlrpcMessageNew uri method_name params = liftIO $ do
    uri' <- textToCString uri
    method_name' <- textToCString method_name
    let params' = unsafeManagedPtrGetPtr params
    onException (do
        result <- propagateGError $ soup_xmlrpc_message_new uri' method_name' params'
        checkUnexpectedReturnNULL "soup_xmlrpc_message_new" result
        result' <- (wrapObject Message) result
        freeMem uri'
        freeMem method_name'
        return result'
     ) (do
        freeMem uri'
        freeMem method_name'
     )


-- function soup_xmlrpc_fault_quark
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_fault_quark" soup_xmlrpc_fault_quark :: 
    IO Word32


xmlrpcFaultQuark ::
    (MonadIO m) =>
    m Word32
xmlrpcFaultQuark  = liftIO $ do
    result <- soup_xmlrpc_fault_quark
    return result


-- function soup_xmlrpc_error_quark
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_error_quark" soup_xmlrpc_error_quark :: 
    IO Word32


xmlrpcErrorQuark ::
    (MonadIO m) =>
    m Word32
xmlrpcErrorQuark  = liftIO $ do
    result <- soup_xmlrpc_error_quark
    return result


-- function soup_xmlrpc_build_response
-- Args : [Arg {argName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "value", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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


xmlrpcBuildResponse ::
    (MonadIO m) =>
    GVariant ->                             -- value
    m T.Text
xmlrpcBuildResponse value = liftIO $ do
    let value' = unsafeManagedPtrGetPtr value
    onException (do
        result <- propagateGError $ soup_xmlrpc_build_response value'
        checkUnexpectedReturnNULL "soup_xmlrpc_build_response" result
        result' <- cstringToText result
        freeMem result
        return result'
     ) (do
        return ()
     )


-- function soup_xmlrpc_build_request
-- Args : [Arg {argName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TVariant, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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


xmlrpcBuildRequest ::
    (MonadIO m) =>
    T.Text ->                               -- method_name
    GVariant ->                             -- params
    m T.Text
xmlrpcBuildRequest method_name params = liftIO $ do
    method_name' <- textToCString method_name
    let params' = unsafeManagedPtrGetPtr params
    onException (do
        result <- propagateGError $ soup_xmlrpc_build_request method_name' params'
        checkUnexpectedReturnNULL "soup_xmlrpc_build_request" result
        result' <- cstringToText result
        freeMem result
        freeMem method_name'
        return result'
     ) (do
        freeMem method_name'
     )


-- function soup_xmlrpc_build_method_response
-- Args : [Arg {argName = "value", argType = TInterface "GObject" "Value", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "value", argType = TInterface "GObject" "Value", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_xmlrpc_build_method_response" soup_xmlrpc_build_method_response :: 
    Ptr GValue ->                           -- value : TInterface "GObject" "Value"
    IO CString

{-# DEPRECATED xmlrpcBuildMethodResponse ["Use soup_xmlrpc_build_response() instead."]#-}
xmlrpcBuildMethodResponse ::
    (MonadIO m) =>
    GValue ->                               -- value
    m T.Text
xmlrpcBuildMethodResponse value = liftIO $ do
    let value' = unsafeManagedPtrGetPtr value
    result <- soup_xmlrpc_build_method_response value'
    checkUnexpectedReturnNULL "soup_xmlrpc_build_method_response" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr value
    return result'


-- function soup_xmlrpc_build_method_call
-- Args : [Arg {argName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TCArray False (-1) 2 (TInterface "GObject" "Value"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "n_params", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : [Arg {argName = "n_params", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- hInArgs : [Arg {argName = "method_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "params", argType = TCArray False (-1) 2 (TInterface "GObject" "Value"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 GValue ->                           -- params : TCArray False (-1) 2 (TInterface "GObject" "Value")
    Int32 ->                                -- n_params : TBasicType TInt32
    IO CString

{-# DEPRECATED xmlrpcBuildMethodCall ["Use soup_xmlrpc_build_request() instead."]#-}
xmlrpcBuildMethodCall ::
    (MonadIO m) =>
    T.Text ->                               -- method_name
    [GValue] ->                             -- params
    m T.Text
xmlrpcBuildMethodCall method_name params = liftIO $ do
    let n_params = fromIntegral $ length params
    method_name' <- textToCString method_name
    let params' = map unsafeManagedPtrGetPtr params
    params'' <- packBlockArray 24 params'
    result <- soup_xmlrpc_build_method_call method_name' params'' n_params
    checkUnexpectedReturnNULL "soup_xmlrpc_build_method_call" result
    result' <- cstringToText result
    freeMem result
    mapM_ touchManagedPtr params
    freeMem method_name'
    freeMem params''
    return result'


-- function soup_websocket_server_process_handshake
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "expected_origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "expected_origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_server_process_handshake" soup_websocket_server_process_handshake :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    CString ->                              -- expected_origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO CInt


websocketServerProcessHandshake ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    Maybe (T.Text) ->                       -- expected_origin
    Maybe ([T.Text]) ->                     -- protocols
    m Bool
websocketServerProcessHandshake msg expected_origin protocols = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    maybeExpected_origin <- case expected_origin of
        Nothing -> return nullPtr
        Just jExpected_origin -> do
            jExpected_origin' <- textToCString jExpected_origin
            return jExpected_origin'
    maybeProtocols <- case protocols of
        Nothing -> return nullPtr
        Just jProtocols -> do
            jProtocols' <- packZeroTerminatedUTF8CArray jProtocols
            return jProtocols'
    result <- soup_websocket_server_process_handshake msg' maybeExpected_origin maybeProtocols
    let result' = (/= 0) result
    touchManagedPtr msg
    freeMem maybeExpected_origin
    mapZeroTerminatedCArray freeMem maybeProtocols
    freeMem maybeProtocols
    return result'


-- function soup_websocket_server_check_handshake
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_server_check_handshake" soup_websocket_server_check_handshake :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    CString ->                              -- origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    Ptr (Ptr GError) ->                     -- error
    IO CInt


websocketServerCheckHandshake ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    Maybe (T.Text) ->                       -- origin
    Maybe ([T.Text]) ->                     -- protocols
    m ()
websocketServerCheckHandshake msg origin protocols = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    maybeOrigin <- case origin of
        Nothing -> return nullPtr
        Just jOrigin -> do
            jOrigin' <- textToCString jOrigin
            return jOrigin'
    maybeProtocols <- case protocols of
        Nothing -> return nullPtr
        Just jProtocols -> do
            jProtocols' <- packZeroTerminatedUTF8CArray jProtocols
            return jProtocols'
    onException (do
        _ <- propagateGError $ soup_websocket_server_check_handshake msg' maybeOrigin maybeProtocols
        touchManagedPtr msg
        freeMem maybeOrigin
        mapZeroTerminatedCArray freeMem maybeProtocols
        freeMem maybeProtocols
        return ()
     ) (do
        freeMem maybeOrigin
        mapZeroTerminatedCArray freeMem maybeProtocols
        freeMem maybeProtocols
     )


-- function soup_websocket_error_get_quark
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_error_get_quark" soup_websocket_error_get_quark :: 
    IO Word32


websocketErrorGetQuark ::
    (MonadIO m) =>
    m Word32
websocketErrorGetQuark  = liftIO $ do
    result <- soup_websocket_error_get_quark
    return result


-- function soup_websocket_client_verify_handshake
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : True
-- Skip return : False

foreign import ccall "soup_websocket_client_verify_handshake" soup_websocket_client_verify_handshake :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    Ptr (Ptr GError) ->                     -- error
    IO CInt


websocketClientVerifyHandshake ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    m ()
websocketClientVerifyHandshake msg = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    onException (do
        _ <- propagateGError $ soup_websocket_client_verify_handshake msg'
        touchManagedPtr msg
        return ()
     ) (do
        return ()
     )


-- function soup_websocket_client_prepare_handshake
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "soup_websocket_client_prepare_handshake" soup_websocket_client_prepare_handshake :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    CString ->                              -- origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    IO ()


websocketClientPrepareHandshake ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    Maybe (T.Text) ->                       -- origin
    Maybe ([T.Text]) ->                     -- protocols
    m ()
websocketClientPrepareHandshake msg origin protocols = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    maybeOrigin <- case origin of
        Nothing -> return nullPtr
        Just jOrigin -> do
            jOrigin' <- textToCString jOrigin
            return jOrigin'
    maybeProtocols <- case protocols of
        Nothing -> return nullPtr
        Just jProtocols -> do
            jProtocols' <- packZeroTerminatedUTF8CArray jProtocols
            return jProtocols'
    soup_websocket_client_prepare_handshake msg' maybeOrigin maybeProtocols
    touchManagedPtr msg
    freeMem maybeOrigin
    mapZeroTerminatedCArray freeMem maybeProtocols
    freeMem maybeProtocols
    return ()


-- function soup_value_hash_new
-- XXX Could not generate function soup_value_hash_new
-- Error was : Not implemented: "GHashTable element of type TInterface \"GObject\" \"Value\" unsupported."

-- function soup_value_hash_insert_value
-- XXX Could not generate function soup_value_hash_insert_value
-- Error was : Not implemented: "GHashTable element of type TInterface \"GObject\" \"Value\" unsupported."

-- function soup_value_array_new
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TInterface "GObject" "ValueArray"
-- throws : False
-- Skip return : False

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

{-# DEPRECATED valueArrayNew ["Use #GVariant API instead."]#-}
valueArrayNew ::
    (MonadIO m) =>
    m GObject.ValueArray
valueArrayNew  = liftIO $ do
    result <- soup_value_array_new
    checkUnexpectedReturnNULL "soup_value_array_new" result
    result' <- (wrapBoxed GObject.ValueArray) result
    return result'


-- function soup_uri_normalize
-- Args : [Arg {argName = "part", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "unescape_extra", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "part", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "unescape_extra", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_uri_normalize" soup_uri_normalize :: 
    CString ->                              -- part : TBasicType TUTF8
    CString ->                              -- unescape_extra : TBasicType TUTF8
    IO CString


uriNormalize ::
    (MonadIO m) =>
    T.Text ->                               -- part
    Maybe (T.Text) ->                       -- unescape_extra
    m T.Text
uriNormalize part unescape_extra = liftIO $ do
    part' <- textToCString part
    maybeUnescape_extra <- case unescape_extra of
        Nothing -> return nullPtr
        Just jUnescape_extra -> do
            jUnescape_extra' <- textToCString jUnescape_extra
            return jUnescape_extra'
    result <- soup_uri_normalize part' maybeUnescape_extra
    checkUnexpectedReturnNULL "soup_uri_normalize" result
    result' <- cstringToText result
    freeMem result
    freeMem part'
    freeMem maybeUnescape_extra
    return result'


-- function soup_uri_encode
-- Args : [Arg {argName = "part", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "escape_extra", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "part", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "escape_extra", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_uri_encode" soup_uri_encode :: 
    CString ->                              -- part : TBasicType TUTF8
    CString ->                              -- escape_extra : TBasicType TUTF8
    IO CString


uriEncode ::
    (MonadIO m) =>
    T.Text ->                               -- part
    Maybe (T.Text) ->                       -- escape_extra
    m T.Text
uriEncode part escape_extra = liftIO $ do
    part' <- textToCString part
    maybeEscape_extra <- case escape_extra of
        Nothing -> return nullPtr
        Just jEscape_extra -> do
            jEscape_extra' <- textToCString jEscape_extra
            return jEscape_extra'
    result <- soup_uri_encode part' maybeEscape_extra
    checkUnexpectedReturnNULL "soup_uri_encode" result
    result' <- cstringToText result
    freeMem result
    freeMem part'
    freeMem maybeEscape_extra
    return result'


-- function soup_uri_decode
-- Args : [Arg {argName = "part", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "part", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_uri_decode" soup_uri_decode :: 
    CString ->                              -- part : TBasicType TUTF8
    IO CString


uriDecode ::
    (MonadIO m) =>
    T.Text ->                               -- part
    m T.Text
uriDecode part = liftIO $ do
    part' <- textToCString part
    result <- soup_uri_decode part'
    checkUnexpectedReturnNULL "soup_uri_decode" result
    result' <- cstringToText result
    freeMem result
    freeMem part'
    return result'


-- function soup_tld_get_base_domain
-- Args : [Arg {argName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "hostname", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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


tldGetBaseDomain ::
    (MonadIO m) =>
    T.Text ->                               -- hostname
    m T.Text
tldGetBaseDomain hostname = liftIO $ do
    hostname' <- textToCString hostname
    onException (do
        result <- propagateGError $ soup_tld_get_base_domain hostname'
        checkUnexpectedReturnNULL "soup_tld_get_base_domain" result
        result' <- cstringToText result
        freeMem hostname'
        return result'
     ) (do
        freeMem hostname'
     )


-- function soup_tld_error_quark
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_tld_error_quark" soup_tld_error_quark :: 
    IO Word32


tldErrorQuark ::
    (MonadIO m) =>
    m Word32
tldErrorQuark  = liftIO $ do
    result <- soup_tld_error_quark
    return result


-- function soup_tld_domain_is_public_suffix
-- Args : [Arg {argName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "domain", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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


tldDomainIsPublicSuffix ::
    (MonadIO m) =>
    T.Text ->                               -- domain
    m Bool
tldDomainIsPublicSuffix domain = liftIO $ do
    domain' <- textToCString domain
    result <- soup_tld_domain_is_public_suffix domain'
    let result' = (/= 0) result
    freeMem domain'
    return result'


-- function soup_str_case_hash
-- Args : [Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "key", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

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


strCaseHash ::
    (MonadIO m) =>
    Ptr () ->                               -- key
    m Word32
strCaseHash key = liftIO $ do
    result <- soup_str_case_hash key
    return result


-- function soup_str_case_equal
-- Args : [Arg {argName = "v1", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "v2", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "v1", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "v2", argType = TBasicType TVoid, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

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


strCaseEqual ::
    (MonadIO m) =>
    Ptr () ->                               -- v1
    Ptr () ->                               -- v2
    m Bool
strCaseEqual v1 v2 = liftIO $ do
    result <- soup_str_case_equal v1 v2
    let result' = (/= 0) result
    return result'


-- function soup_status_proxify
-- Args : [Arg {argName = "status_code", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "status_code", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_status_proxify" soup_status_proxify :: 
    Word32 ->                               -- status_code : TBasicType TUInt32
    IO Word32


statusProxify ::
    (MonadIO m) =>
    Word32 ->                               -- status_code
    m Word32
statusProxify status_code = liftIO $ do
    result <- soup_status_proxify status_code
    return result


-- function soup_status_get_phrase
-- Args : [Arg {argName = "status_code", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "status_code", argType = TBasicType TUInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_status_get_phrase" soup_status_get_phrase :: 
    Word32 ->                               -- status_code : TBasicType TUInt32
    IO CString


statusGetPhrase ::
    (MonadIO m) =>
    Word32 ->                               -- status_code
    m T.Text
statusGetPhrase status_code = liftIO $ do
    result <- soup_status_get_phrase status_code
    checkUnexpectedReturnNULL "soup_status_get_phrase" result
    result' <- cstringToText result
    return result'


-- function soup_requester_error_quark
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_requester_error_quark" soup_requester_error_quark :: 
    IO Word32


requesterErrorQuark ::
    (MonadIO m) =>
    m Word32
requesterErrorQuark  = liftIO $ do
    result <- soup_requester_error_quark
    return result


-- function soup_request_error_quark
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_request_error_quark" soup_request_error_quark :: 
    IO Word32


requestErrorQuark ::
    (MonadIO m) =>
    m Word32
requestErrorQuark  = liftIO $ do
    result <- soup_request_error_quark
    return result


-- function soup_message_headers_iter_init
-- Args : [Arg {argName = "iter", argType = TInterface "Soup" "MessageHeadersIter", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "hdrs", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "hdrs", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "soup_message_headers_iter_init" soup_message_headers_iter_init :: 
    Ptr MessageHeadersIter ->               -- iter : TInterface "Soup" "MessageHeadersIter"
    Ptr MessageHeaders ->                   -- hdrs : TInterface "Soup" "MessageHeaders"
    IO ()


messageHeadersIterInit ::
    (MonadIO m) =>
    MessageHeaders ->                       -- hdrs
    m (MessageHeadersIter)
messageHeadersIterInit hdrs = liftIO $ do
    iter <- callocBytes 24 :: IO (Ptr MessageHeadersIter)
    let hdrs' = unsafeManagedPtrGetPtr hdrs
    soup_message_headers_iter_init iter hdrs'
    iter' <- (wrapPtr MessageHeadersIter) iter
    touchManagedPtr hdrs
    return iter'


-- function soup_http_error_quark
-- Args : []
-- Lengths : []
-- hInArgs : []
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_http_error_quark" soup_http_error_quark :: 
    IO Word32


httpErrorQuark ::
    (MonadIO m) =>
    m Word32
httpErrorQuark  = liftIO $ do
    result <- soup_http_error_quark
    return result


-- function soup_headers_parse_status_line
-- Args : [Arg {argName = "status_line", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "ver", argType = TInterface "Soup" "HTTPVersion", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "status_code", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "reason_phrase", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "status_line", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 "Soup" "HTTPVersion"
    Ptr Word32 ->                           -- status_code : TBasicType TUInt32
    Ptr CString ->                          -- reason_phrase : TBasicType TUTF8
    IO CInt


headersParseStatusLine ::
    (MonadIO m) =>
    T.Text ->                               -- status_line
    m (Bool,HTTPVersion,Word32,T.Text)
headersParseStatusLine status_line = liftIO $ do
    status_line' <- textToCString status_line
    ver <- allocMem :: IO (Ptr CUInt)
    status_code <- allocMem :: IO (Ptr Word32)
    reason_phrase <- allocMem :: IO (Ptr CString)
    result <- soup_headers_parse_status_line status_line' ver status_code reason_phrase
    let result' = (/= 0) result
    ver' <- peek ver
    let ver'' = (toEnum . fromIntegral) ver'
    status_code' <- peek status_code
    reason_phrase' <- peek reason_phrase
    reason_phrase'' <- cstringToText reason_phrase'
    freeMem reason_phrase'
    freeMem status_line'
    freeMem ver
    freeMem status_code
    freeMem reason_phrase
    return (result', ver'', status_code', reason_phrase'')


-- function soup_headers_parse_response
-- Args : [Arg {argName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "headers", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "ver", argType = TInterface "Soup" "HTTPVersion", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "status_code", argType = TBasicType TUInt32, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "reason_phrase", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "headers", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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 TInt32
    Ptr MessageHeaders ->                   -- headers : TInterface "Soup" "MessageHeaders"
    Ptr CUInt ->                            -- ver : TInterface "Soup" "HTTPVersion"
    Ptr Word32 ->                           -- status_code : TBasicType TUInt32
    Ptr CString ->                          -- reason_phrase : TBasicType TUTF8
    IO CInt


headersParseResponse ::
    (MonadIO m) =>
    T.Text ->                               -- str
    Int32 ->                                -- len
    MessageHeaders ->                       -- headers
    m (Bool,HTTPVersion,Word32,T.Text)
headersParseResponse str len headers = liftIO $ do
    str' <- textToCString str
    let headers' = unsafeManagedPtrGetPtr headers
    ver <- allocMem :: IO (Ptr CUInt)
    status_code <- allocMem :: IO (Ptr Word32)
    reason_phrase <- allocMem :: IO (Ptr CString)
    result <- soup_headers_parse_response str' len headers' ver status_code reason_phrase
    let result' = (/= 0) result
    ver' <- peek ver
    let ver'' = (toEnum . fromIntegral) ver'
    status_code' <- peek status_code
    reason_phrase' <- peek reason_phrase
    reason_phrase'' <- cstringToText reason_phrase'
    freeMem reason_phrase'
    touchManagedPtr headers
    freeMem str'
    freeMem ver
    freeMem status_code
    freeMem reason_phrase
    return (result', ver'', status_code', reason_phrase'')


-- function soup_headers_parse_request
-- Args : [Arg {argName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "req_headers", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "req_method", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "req_path", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "ver", argType = TInterface "Soup" "HTTPVersion", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "req_headers", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUInt32
-- throws : False
-- Skip return : False

foreign import ccall "soup_headers_parse_request" soup_headers_parse_request :: 
    CString ->                              -- str : TBasicType TUTF8
    Int32 ->                                -- len : TBasicType TInt32
    Ptr MessageHeaders ->                   -- req_headers : TInterface "Soup" "MessageHeaders"
    Ptr CString ->                          -- req_method : TBasicType TUTF8
    Ptr CString ->                          -- req_path : TBasicType TUTF8
    Ptr CUInt ->                            -- ver : TInterface "Soup" "HTTPVersion"
    IO Word32


headersParseRequest ::
    (MonadIO m) =>
    T.Text ->                               -- str
    Int32 ->                                -- len
    MessageHeaders ->                       -- req_headers
    m (Word32,T.Text,T.Text,HTTPVersion)
headersParseRequest str len req_headers = liftIO $ do
    str' <- textToCString str
    let req_headers' = unsafeManagedPtrGetPtr req_headers
    req_method <- allocMem :: IO (Ptr CString)
    req_path <- allocMem :: IO (Ptr CString)
    ver <- allocMem :: IO (Ptr CUInt)
    result <- soup_headers_parse_request str' len req_headers' req_method req_path ver
    req_method' <- peek req_method
    req_method'' <- cstringToText req_method'
    freeMem req_method'
    req_path' <- peek req_path
    req_path'' <- cstringToText req_path'
    freeMem req_path'
    ver' <- peek ver
    let ver'' = (toEnum . fromIntegral) ver'
    touchManagedPtr req_headers
    freeMem str'
    freeMem req_method
    freeMem req_path
    freeMem ver
    return (result, req_method'', req_path'', ver'')


-- function soup_headers_parse
-- Args : [Arg {argName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "dest", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "str", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "len", argType = TBasicType TInt32, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "dest", argType = TInterface "Soup" "MessageHeaders", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TBoolean
-- throws : False
-- Skip return : False

foreign import ccall "soup_headers_parse" soup_headers_parse :: 
    CString ->                              -- str : TBasicType TUTF8
    Int32 ->                                -- len : TBasicType TInt32
    Ptr MessageHeaders ->                   -- dest : TInterface "Soup" "MessageHeaders"
    IO CInt


headersParse ::
    (MonadIO m) =>
    T.Text ->                               -- str
    Int32 ->                                -- len
    MessageHeaders ->                       -- dest
    m Bool
headersParse str len dest = liftIO $ do
    str' <- textToCString str
    let dest' = unsafeManagedPtrGetPtr dest
    result <- soup_headers_parse str' len dest'
    let result' = (/= 0) result
    touchManagedPtr dest
    freeMem str'
    return result'


-- function soup_header_parse_semi_param_list
-- Args : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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))


headerParseSemiParamList ::
    (MonadIO m) =>
    T.Text ->                               -- header
    m (Map.Map T.Text T.Text)
headerParseSemiParamList header = liftIO $ do
    header' <- textToCString header
    result <- soup_header_parse_semi_param_list header'
    checkUnexpectedReturnNULL "soup_header_parse_semi_param_list" result
    result' <- unpackGHashTable result
    let result'' = mapFirst cstringUnpackPtr result'
    result''' <- mapFirstA cstringToText result''
    let result'''' = mapSecond cstringUnpackPtr result'''
    result''''' <- mapSecondA cstringToText result''''
    let result'''''' = Map.fromList result'''''
    unrefGHashTable result
    freeMem header'
    return result''''''


-- function soup_header_parse_quality_list
-- Args : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "unacceptable", argType = TGSList (TBasicType TUTF8), direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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))


headerParseQualityList ::
    (MonadIO m) =>
    T.Text ->                               -- header
    m ([T.Text],[T.Text])
headerParseQualityList header = liftIO $ do
    header' <- textToCString header
    unacceptable <- allocMem :: IO (Ptr (Ptr (GSList CString)))
    result <- soup_header_parse_quality_list header' unacceptable
    checkUnexpectedReturnNULL "soup_header_parse_quality_list" result
    result' <- unpackGSList result
    result'' <- mapM cstringToText result'
    mapGSList freeMem result
    g_slist_free result
    unacceptable' <- peek unacceptable
    unacceptable'' <- unpackGSList unacceptable'
    unacceptable''' <- mapM cstringToText unacceptable''
    mapGSList freeMem unacceptable'
    g_slist_free unacceptable'
    freeMem header'
    freeMem unacceptable
    return (result'', unacceptable''')


-- function soup_header_parse_param_list
-- Args : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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))


headerParseParamList ::
    (MonadIO m) =>
    T.Text ->                               -- header
    m (Map.Map T.Text T.Text)
headerParseParamList header = liftIO $ do
    header' <- textToCString header
    result <- soup_header_parse_param_list header'
    checkUnexpectedReturnNULL "soup_header_parse_param_list" result
    result' <- unpackGHashTable result
    let result'' = mapFirst cstringUnpackPtr result'
    result''' <- mapFirstA cstringToText result''
    let result'''' = mapSecond cstringUnpackPtr result'''
    result''''' <- mapSecondA cstringToText result''''
    let result'''''' = Map.fromList result'''''
    unrefGHashTable result
    freeMem header'
    return result''''''


-- function soup_header_parse_list
-- Args : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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))


headerParseList ::
    (MonadIO m) =>
    T.Text ->                               -- header
    m [T.Text]
headerParseList header = liftIO $ do
    header' <- textToCString header
    result <- soup_header_parse_list header'
    checkUnexpectedReturnNULL "soup_header_parse_list" result
    result' <- unpackGSList result
    result'' <- mapM cstringToText result'
    mapGSList freeMem result
    g_slist_free result
    freeMem header'
    return result''


-- function soup_header_g_string_append_param_quoted
-- Args : [Arg {argName = "string", argType = TInterface "GLib" "String", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "string", argType = TInterface "GLib" "String", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- 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 : TInterface "GLib" "String"
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()


headerGStringAppendParamQuoted ::
    (MonadIO m) =>
    GLib.String ->                          -- string
    T.Text ->                               -- name
    T.Text ->                               -- value
    m ()
headerGStringAppendParamQuoted string name value = liftIO $ do
    let string' = unsafeManagedPtrGetPtr string
    name' <- textToCString name
    value' <- textToCString value
    soup_header_g_string_append_param_quoted string' name' value'
    touchManagedPtr string
    freeMem name'
    freeMem value'
    return ()


-- function soup_header_g_string_append_param
-- Args : [Arg {argName = "string", argType = TInterface "GLib" "String", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "string", argType = TInterface "GLib" "String", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "value", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "soup_header_g_string_append_param" soup_header_g_string_append_param :: 
    Ptr GLib.String ->                      -- string : TInterface "GLib" "String"
    CString ->                              -- name : TBasicType TUTF8
    CString ->                              -- value : TBasicType TUTF8
    IO ()


headerGStringAppendParam ::
    (MonadIO m) =>
    GLib.String ->                          -- string
    T.Text ->                               -- name
    T.Text ->                               -- value
    m ()
headerGStringAppendParam string name value = liftIO $ do
    let string' = unsafeManagedPtrGetPtr string
    name' <- textToCString name
    value' <- textToCString value
    soup_header_g_string_append_param string' name' value'
    touchManagedPtr string
    freeMem name'
    freeMem value'
    return ()


-- function soup_header_free_param_list
-- Args : [Arg {argName = "param_list", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "param_list", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- 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 ()


headerFreeParamList ::
    (MonadIO m) =>
    Map.Map T.Text T.Text ->                -- param_list
    m ()
headerFreeParamList param_list = liftIO $ do
    let param_list' = Map.toList param_list
    param_list'' <- mapFirstA textToCString param_list'
    param_list''' <- mapSecondA textToCString param_list''
    let param_list'''' = mapFirst cstringPackPtr param_list'''
    let param_list''''' = mapSecond cstringPackPtr param_list''''
    param_list'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) param_list'''''
    soup_header_free_param_list param_list''''''
    unrefGHashTable param_list''''''
    return ()


-- function soup_header_contains
-- Args : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "token", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "token", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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


headerContains ::
    (MonadIO m) =>
    T.Text ->                               -- header
    T.Text ->                               -- token
    m Bool
headerContains header token = liftIO $ do
    header' <- textToCString header
    token' <- textToCString token
    result <- soup_header_contains header' token'
    let result' = (/= 0) result
    freeMem header'
    freeMem token'
    return result'


-- function soup_form_request_new_from_multipart
-- Args : [Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "multipart", argType = TInterface "Soup" "Multipart", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "multipart", argType = TInterface "Soup" "Multipart", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "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 Multipart ->                        -- multipart : TInterface "Soup" "Multipart"
    IO (Ptr Message)


formRequestNewFromMultipart ::
    (MonadIO m) =>
    T.Text ->                               -- uri
    Multipart ->                            -- multipart
    m Message
formRequestNewFromMultipart uri multipart = liftIO $ do
    uri' <- textToCString uri
    let multipart' = unsafeManagedPtrGetPtr multipart
    result <- soup_form_request_new_from_multipart uri' multipart'
    checkUnexpectedReturnNULL "soup_form_request_new_from_multipart" result
    result' <- (wrapObject Message) result
    touchManagedPtr multipart
    freeMem uri'
    return result'


-- function soup_form_request_new_from_hash
-- Args : [Arg {argName = "method", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "form_data_set", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "method", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "form_data_set", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "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 Message)


formRequestNewFromHash ::
    (MonadIO m) =>
    T.Text ->                               -- method
    T.Text ->                               -- uri
    Map.Map T.Text T.Text ->                -- form_data_set
    m Message
formRequestNewFromHash method uri form_data_set = liftIO $ do
    method' <- textToCString method
    uri' <- textToCString uri
    let form_data_set' = Map.toList form_data_set
    form_data_set'' <- mapFirstA textToCString form_data_set'
    form_data_set''' <- mapSecondA textToCString form_data_set''
    let form_data_set'''' = mapFirst cstringPackPtr form_data_set'''
    let form_data_set''''' = mapSecond cstringPackPtr form_data_set''''
    form_data_set'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) form_data_set'''''
    result <- soup_form_request_new_from_hash method' uri' form_data_set''''''
    checkUnexpectedReturnNULL "soup_form_request_new_from_hash" result
    result' <- (wrapObject Message) result
    freeMem method'
    freeMem uri'
    unrefGHashTable form_data_set''''''
    return result'


-- function soup_form_request_new_from_datalist
-- Args : [Arg {argName = "method", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "form_data_set", argType = TInterface "GLib" "Data", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "method", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "uri", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "form_data_set", argType = TInterface "GLib" "Data", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "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 ->                        -- form_data_set : TInterface "GLib" "Data"
    IO (Ptr Message)


formRequestNewFromDatalist ::
    (MonadIO m) =>
    T.Text ->                               -- method
    T.Text ->                               -- uri
    GLib.Data ->                            -- form_data_set
    m Message
formRequestNewFromDatalist method uri form_data_set = liftIO $ do
    method' <- textToCString method
    uri' <- textToCString uri
    let form_data_set' = unsafeManagedPtrGetPtr form_data_set
    result <- soup_form_request_new_from_datalist method' uri' form_data_set'
    checkUnexpectedReturnNULL "soup_form_request_new_from_datalist" result
    result' <- (wrapObject Message) result
    touchManagedPtr form_data_set
    freeMem method'
    freeMem uri'
    return result'


-- function soup_form_encode_hash
-- Args : [Arg {argName = "form_data_set", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "form_data_set", argType = TGHash (TBasicType TUTF8) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : 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


formEncodeHash ::
    (MonadIO m) =>
    Map.Map T.Text T.Text ->                -- form_data_set
    m T.Text
formEncodeHash form_data_set = liftIO $ do
    let form_data_set' = Map.toList form_data_set
    form_data_set'' <- mapFirstA textToCString form_data_set'
    form_data_set''' <- mapSecondA textToCString form_data_set''
    let form_data_set'''' = mapFirst cstringPackPtr form_data_set'''
    let form_data_set''''' = mapSecond cstringPackPtr form_data_set''''
    form_data_set'''''' <- packGHashTable gStrHash gStrEqual (Just ptr_to_g_free) (Just ptr_to_g_free) form_data_set'''''
    result <- soup_form_encode_hash form_data_set''''''
    checkUnexpectedReturnNULL "soup_form_encode_hash" result
    result' <- cstringToText result
    freeMem result
    unrefGHashTable form_data_set''''''
    return result'


-- function soup_form_encode_datalist
-- Args : [Arg {argName = "form_data_set", argType = TInterface "GLib" "Data", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "form_data_set", argType = TInterface "GLib" "Data", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_encode_datalist" soup_form_encode_datalist :: 
    Ptr GLib.Data ->                        -- form_data_set : TInterface "GLib" "Data"
    IO CString


formEncodeDatalist ::
    (MonadIO m) =>
    GLib.Data ->                            -- form_data_set
    m T.Text
formEncodeDatalist form_data_set = liftIO $ do
    let form_data_set' = unsafeManagedPtrGetPtr form_data_set
    result <- soup_form_encode_datalist form_data_set'
    checkUnexpectedReturnNULL "soup_form_encode_datalist" result
    result' <- cstringToText result
    freeMem result
    touchManagedPtr form_data_set
    return result'


-- function soup_form_decode_multipart
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "file_control_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "filename", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "content_type", argType = TBasicType TUTF8, direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything},Arg {argName = "file", argType = TInterface "Soup" "Buffer", direction = DirectionOut, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferEverything}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "file_control_name", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_decode_multipart" soup_form_decode_multipart :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    CString ->                              -- file_control_name : TBasicType TUTF8
    Ptr CString ->                          -- filename : TBasicType TUTF8
    Ptr CString ->                          -- content_type : TBasicType TUTF8
    Ptr Buffer ->                           -- file : TInterface "Soup" "Buffer"
    IO (Ptr (GHashTable CString CString))


formDecodeMultipart ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    Maybe (T.Text) ->                       -- file_control_name
    m ((Map.Map T.Text T.Text),T.Text,T.Text,Buffer)
formDecodeMultipart msg file_control_name = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    maybeFile_control_name <- case file_control_name of
        Nothing -> return nullPtr
        Just jFile_control_name -> do
            jFile_control_name' <- textToCString jFile_control_name
            return jFile_control_name'
    filename <- allocMem :: IO (Ptr CString)
    content_type <- allocMem :: IO (Ptr CString)
    file <- callocBoxedBytes 16 :: IO (Ptr Buffer)
    result <- soup_form_decode_multipart msg' maybeFile_control_name filename content_type file
    checkUnexpectedReturnNULL "soup_form_decode_multipart" result
    result' <- unpackGHashTable result
    let result'' = mapFirst cstringUnpackPtr result'
    result''' <- mapFirstA cstringToText result''
    let result'''' = mapSecond cstringUnpackPtr result'''
    result''''' <- mapSecondA cstringToText result''''
    let result'''''' = Map.fromList result'''''
    unrefGHashTable result
    filename' <- peek filename
    filename'' <- cstringToText filename'
    freeMem filename'
    content_type' <- peek content_type
    content_type'' <- cstringToText content_type'
    freeMem content_type'
    file' <- (wrapBoxed Buffer) file
    touchManagedPtr msg
    freeMem maybeFile_control_name
    freeMem filename
    freeMem content_type
    return (result'''''', filename'', content_type'', file')


-- function soup_form_decode
-- Args : [Arg {argName = "encoded_form", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "encoded_form", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGHash (TBasicType TUTF8) (TBasicType TUTF8)
-- throws : False
-- Skip return : False

foreign import ccall "soup_form_decode" soup_form_decode :: 
    CString ->                              -- encoded_form : TBasicType TUTF8
    IO (Ptr (GHashTable CString CString))


formDecode ::
    (MonadIO m) =>
    T.Text ->                               -- encoded_form
    m (Map.Map T.Text T.Text)
formDecode encoded_form = liftIO $ do
    encoded_form' <- textToCString encoded_form
    result <- soup_form_decode encoded_form'
    checkUnexpectedReturnNULL "soup_form_decode" result
    result' <- unpackGHashTable result
    let result'' = mapFirst cstringUnpackPtr result'
    result''' <- mapFirstA cstringToText result''
    let result'''' = mapSecond cstringUnpackPtr result'''
    result''''' <- mapSecondA cstringToText result''''
    let result'''''' = Map.fromList result'''''
    unrefGHashTable result
    freeMem encoded_form'
    return result''''''


-- function soup_cookies_to_response
-- Args : [Arg {argName = "cookies", argType = TGSList (TInterface "Soup" "Cookie"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "cookies", argType = TGSList (TInterface "Soup" "Cookie"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_to_response" soup_cookies_to_response :: 
    Ptr (GSList (Ptr Cookie)) ->            -- cookies : TGSList (TInterface "Soup" "Cookie")
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    IO ()


cookiesToResponse ::
    (MonadIO m, MessageK a) =>
    [Cookie] ->                             -- cookies
    a ->                                    -- msg
    m ()
cookiesToResponse cookies msg = liftIO $ do
    let cookies' = map unsafeManagedPtrGetPtr cookies
    cookies'' <- packGSList cookies'
    let msg' = unsafeManagedPtrCastPtr msg
    soup_cookies_to_response cookies'' msg'
    mapM_ touchManagedPtr cookies
    touchManagedPtr msg
    g_slist_free cookies''
    return ()


-- function soup_cookies_to_request
-- Args : [Arg {argName = "cookies", argType = TGSList (TInterface "Soup" "Cookie"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "cookies", argType = TGSList (TInterface "Soup" "Cookie"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TVoid
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_to_request" soup_cookies_to_request :: 
    Ptr (GSList (Ptr Cookie)) ->            -- cookies : TGSList (TInterface "Soup" "Cookie")
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    IO ()


cookiesToRequest ::
    (MonadIO m, MessageK a) =>
    [Cookie] ->                             -- cookies
    a ->                                    -- msg
    m ()
cookiesToRequest cookies msg = liftIO $ do
    let cookies' = map unsafeManagedPtrGetPtr cookies
    cookies'' <- packGSList cookies'
    let msg' = unsafeManagedPtrCastPtr msg
    soup_cookies_to_request cookies'' msg'
    mapM_ touchManagedPtr cookies
    touchManagedPtr msg
    g_slist_free cookies''
    return ()


-- function soup_cookies_to_cookie_header
-- Args : [Arg {argName = "cookies", argType = TGSList (TInterface "Soup" "Cookie"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "cookies", argType = TGSList (TInterface "Soup" "Cookie"), direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TBasicType TUTF8
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_to_cookie_header" soup_cookies_to_cookie_header :: 
    Ptr (GSList (Ptr Cookie)) ->            -- cookies : TGSList (TInterface "Soup" "Cookie")
    IO CString


cookiesToCookieHeader ::
    (MonadIO m) =>
    [Cookie] ->                             -- cookies
    m T.Text
cookiesToCookieHeader cookies = liftIO $ do
    let cookies' = map unsafeManagedPtrGetPtr cookies
    cookies'' <- packGSList cookies'
    result <- soup_cookies_to_cookie_header cookies''
    checkUnexpectedReturnNULL "soup_cookies_to_cookie_header" result
    result' <- cstringToText result
    freeMem result
    mapM_ touchManagedPtr cookies
    g_slist_free cookies''
    return result'


-- function soup_cookies_from_response
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGSList (TInterface "Soup" "Cookie")
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_from_response" soup_cookies_from_response :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    IO (Ptr (GSList (Ptr Cookie)))


cookiesFromResponse ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    m [Cookie]
cookiesFromResponse msg = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    result <- soup_cookies_from_response msg'
    checkUnexpectedReturnNULL "soup_cookies_from_response" result
    result' <- unpackGSList result
    result'' <- mapM (wrapBoxed Cookie) result'
    g_slist_free result
    touchManagedPtr msg
    return result''


-- function soup_cookies_from_request
-- Args : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "msg", argType = TInterface "Soup" "Message", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TGSList (TInterface "Soup" "Cookie")
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookies_from_request" soup_cookies_from_request :: 
    Ptr Message ->                          -- msg : TInterface "Soup" "Message"
    IO (Ptr (GSList (Ptr Cookie)))


cookiesFromRequest ::
    (MonadIO m, MessageK a) =>
    a ->                                    -- msg
    m [Cookie]
cookiesFromRequest msg = liftIO $ do
    let msg' = unsafeManagedPtrCastPtr msg
    result <- soup_cookies_from_request msg'
    checkUnexpectedReturnNULL "soup_cookies_from_request" result
    result' <- unpackGSList result
    result'' <- mapM (wrapBoxed Cookie) result'
    g_slist_free result
    touchManagedPtr msg
    return result''


-- function soup_cookie_parse
-- Args : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "origin", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- Lengths : []
-- hInArgs : [Arg {argName = "header", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing},Arg {argName = "origin", argType = TInterface "Soup" "URI", direction = DirectionIn, mayBeNull = False, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, transfer = TransferNothing}]
-- returnType : TInterface "Soup" "Cookie"
-- throws : False
-- Skip return : False

foreign import ccall "soup_cookie_parse" soup_cookie_parse :: 
    CString ->                              -- header : TBasicType TUTF8
    Ptr URI ->                              -- origin : TInterface "Soup" "URI"
    IO (Ptr Cookie)


cookieParse ::
    (MonadIO m) =>
    T.Text ->                               -- header
    URI ->                                  -- origin
    m Cookie
cookieParse header origin = liftIO $ do
    header' <- textToCString header
    let origin' = unsafeManagedPtrGetPtr origin
    result <- soup_cookie_parse header' origin'
    checkUnexpectedReturnNULL "soup_cookie_parse" result
    result' <- (wrapBoxed Cookie) result
    touchManagedPtr origin
    freeMem header'
    return result'