{- |
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.Objects.Server
    ( 

-- * Exported types
    Server(..)                              ,
    IsServer                                ,
    toServer                                ,
    noServer                                ,


 -- * Methods
-- ** acceptIostream #method:acceptIostream#
    ServerAcceptIostreamMethodInfo          ,
    serverAcceptIostream                    ,


-- ** addAuthDomain #method:addAuthDomain#
    ServerAddAuthDomainMethodInfo           ,
    serverAddAuthDomain                     ,


-- ** addEarlyHandler #method:addEarlyHandler#
    ServerAddEarlyHandlerMethodInfo         ,
    serverAddEarlyHandler                   ,


-- ** addHandler #method:addHandler#
    ServerAddHandlerMethodInfo              ,
    serverAddHandler                        ,


-- ** addWebsocketHandler #method:addWebsocketHandler#
    ServerAddWebsocketHandlerMethodInfo     ,
    serverAddWebsocketHandler               ,


-- ** disconnect #method:disconnect#
    ServerDisconnectMethodInfo              ,
    serverDisconnect                        ,


-- ** getAsyncContext #method:getAsyncContext#
    ServerGetAsyncContextMethodInfo         ,
    serverGetAsyncContext                   ,


-- ** getListener #method:getListener#
    ServerGetListenerMethodInfo             ,
    serverGetListener                       ,


-- ** getListeners #method:getListeners#
    ServerGetListenersMethodInfo            ,
    serverGetListeners                      ,


-- ** getPort #method:getPort#
    ServerGetPortMethodInfo                 ,
    serverGetPort                           ,


-- ** getUris #method:getUris#
    ServerGetUrisMethodInfo                 ,
    serverGetUris                           ,


-- ** isHttps #method:isHttps#
    ServerIsHttpsMethodInfo                 ,
    serverIsHttps                           ,


-- ** listen #method:listen#
    ServerListenMethodInfo                  ,
    serverListen                            ,


-- ** listenAll #method:listenAll#
    ServerListenAllMethodInfo               ,
    serverListenAll                         ,


-- ** listenFd #method:listenFd#
    ServerListenFdMethodInfo                ,
    serverListenFd                          ,


-- ** listenLocal #method:listenLocal#
    ServerListenLocalMethodInfo             ,
    serverListenLocal                       ,


-- ** listenSocket #method:listenSocket#
    ServerListenSocketMethodInfo            ,
    serverListenSocket                      ,


-- ** pauseMessage #method:pauseMessage#
    ServerPauseMessageMethodInfo            ,
    serverPauseMessage                      ,


-- ** quit #method:quit#
    ServerQuitMethodInfo                    ,
    serverQuit                              ,


-- ** removeAuthDomain #method:removeAuthDomain#
    ServerRemoveAuthDomainMethodInfo        ,
    serverRemoveAuthDomain                  ,


-- ** removeHandler #method:removeHandler#
    ServerRemoveHandlerMethodInfo           ,
    serverRemoveHandler                     ,


-- ** run #method:run#
    ServerRunMethodInfo                     ,
    serverRun                               ,


-- ** runAsync #method:runAsync#
    ServerRunAsyncMethodInfo                ,
    serverRunAsync                          ,


-- ** setSslCertFile #method:setSslCertFile#
    ServerSetSslCertFileMethodInfo          ,
    serverSetSslCertFile                    ,


-- ** unpauseMessage #method:unpauseMessage#
    ServerUnpauseMessageMethodInfo          ,
    serverUnpauseMessage                    ,




 -- * Properties
-- ** asyncContext #attr:asyncContext#
    ServerAsyncContextPropertyInfo          ,
    constructServerAsyncContext             ,
    getServerAsyncContext                   ,
    serverAsyncContext                      ,


-- ** httpAliases #attr:httpAliases#
    ServerHttpAliasesPropertyInfo           ,
    clearServerHttpAliases                  ,
    constructServerHttpAliases              ,
    getServerHttpAliases                    ,
    serverHttpAliases                       ,
    setServerHttpAliases                    ,


-- ** httpsAliases #attr:httpsAliases#
    ServerHttpsAliasesPropertyInfo          ,
    clearServerHttpsAliases                 ,
    constructServerHttpsAliases             ,
    getServerHttpsAliases                   ,
    serverHttpsAliases                      ,
    setServerHttpsAliases                   ,


-- ** interface #attr:interface#
    ServerInterfacePropertyInfo             ,
    constructServerInterface                ,
    getServerInterface                      ,
    serverInterface                         ,


-- ** port #attr:port#
    ServerPortPropertyInfo                  ,
    constructServerPort                     ,
    getServerPort                           ,
    serverPort                              ,


-- ** rawPaths #attr:rawPaths#
    ServerRawPathsPropertyInfo              ,
    constructServerRawPaths                 ,
    getServerRawPaths                       ,
    serverRawPaths                          ,


-- ** serverHeader #attr:serverHeader#
    ServerServerHeaderPropertyInfo          ,
    clearServerServerHeader                 ,
    constructServerServerHeader             ,
    getServerServerHeader                   ,
    serverServerHeader                      ,
    setServerServerHeader                   ,


-- ** sslCertFile #attr:sslCertFile#
    ServerSslCertFilePropertyInfo           ,
    constructServerSslCertFile              ,
    getServerSslCertFile                    ,
    serverSslCertFile                       ,


-- ** sslKeyFile #attr:sslKeyFile#
    ServerSslKeyFilePropertyInfo            ,
    constructServerSslKeyFile               ,
    getServerSslKeyFile                     ,
    serverSslKeyFile                        ,


-- ** tlsCertificate #attr:tlsCertificate#
    ServerTlsCertificatePropertyInfo        ,
    constructServerTlsCertificate           ,
    getServerTlsCertificate                 ,
    serverTlsCertificate                    ,




 -- * Signals
-- ** requestAborted #signal:requestAborted#
    C_ServerRequestAbortedCallback          ,
    ServerRequestAbortedCallback            ,
    ServerRequestAbortedSignalInfo          ,
    afterServerRequestAborted               ,
    genClosure_ServerRequestAborted         ,
    mk_ServerRequestAbortedCallback         ,
    noServerRequestAbortedCallback          ,
    onServerRequestAborted                  ,
    wrap_ServerRequestAbortedCallback       ,


-- ** requestFinished #signal:requestFinished#
    C_ServerRequestFinishedCallback         ,
    ServerRequestFinishedCallback           ,
    ServerRequestFinishedSignalInfo         ,
    afterServerRequestFinished              ,
    genClosure_ServerRequestFinished        ,
    mk_ServerRequestFinishedCallback        ,
    noServerRequestFinishedCallback         ,
    onServerRequestFinished                 ,
    wrap_ServerRequestFinishedCallback      ,


-- ** requestRead #signal:requestRead#
    C_ServerRequestReadCallback             ,
    ServerRequestReadCallback               ,
    ServerRequestReadSignalInfo             ,
    afterServerRequestRead                  ,
    genClosure_ServerRequestRead            ,
    mk_ServerRequestReadCallback            ,
    noServerRequestReadCallback             ,
    onServerRequestRead                     ,
    wrap_ServerRequestReadCallback          ,


-- ** requestStarted #signal:requestStarted#
    C_ServerRequestStartedCallback          ,
    ServerRequestStartedCallback            ,
    ServerRequestStartedSignalInfo          ,
    afterServerRequestStarted               ,
    genClosure_ServerRequestStarted         ,
    mk_ServerRequestStartedCallback         ,
    noServerRequestStartedCallback          ,
    onServerRequestStarted                  ,
    wrap_ServerRequestStartedCallback       ,




    ) where

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

import qualified Data.GI.Base.Attributes as GI.Attributes
import qualified Data.GI.Base.ManagedPtr as B.ManagedPtr
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP

import qualified GI.GLib.Callbacks as GLib.Callbacks
import qualified GI.GLib.Structs.MainContext as GLib.MainContext
import qualified GI.GObject.Objects.Object as GObject.Object
import qualified GI.Gio.Objects.IOStream as Gio.IOStream
import qualified GI.Gio.Objects.Socket as Gio.Socket
import qualified GI.Gio.Objects.SocketAddress as Gio.SocketAddress
import qualified GI.Gio.Objects.TlsCertificate as Gio.TlsCertificate
import qualified GI.Soup.Callbacks as Soup.Callbacks
import {-# SOURCE #-} qualified GI.Soup.Flags as Soup.Flags
import {-# SOURCE #-} qualified GI.Soup.Objects.Address as Soup.Address
import {-# SOURCE #-} qualified GI.Soup.Objects.AuthDomain as Soup.AuthDomain
import {-# SOURCE #-} qualified GI.Soup.Objects.Message as Soup.Message
import {-# SOURCE #-} qualified GI.Soup.Objects.Socket as Soup.Socket
import {-# SOURCE #-} qualified GI.Soup.Structs.ClientContext as Soup.ClientContext
import {-# SOURCE #-} qualified GI.Soup.Structs.URI as Soup.URI

newtype Server = Server (ManagedPtr Server)
foreign import ccall "soup_server_get_type"
    c_soup_server_get_type :: IO GType

instance GObject Server where
    gobjectType _ = c_soup_server_get_type
    

class GObject o => IsServer o
#if MIN_VERSION_base(4,9,0)
instance {-# OVERLAPPABLE #-} (GObject a, O.UnknownAncestorError Server a) =>
    IsServer a
#endif
instance IsServer Server
instance GObject.Object.IsObject Server

toServer :: IsServer o => o -> IO Server
toServer = unsafeCastTo Server

noServer :: Maybe Server
noServer = Nothing

type family ResolveServerMethod (t :: Symbol) (o :: *) :: * where
    ResolveServerMethod "acceptIostream" o = ServerAcceptIostreamMethodInfo
    ResolveServerMethod "addAuthDomain" o = ServerAddAuthDomainMethodInfo
    ResolveServerMethod "addEarlyHandler" o = ServerAddEarlyHandlerMethodInfo
    ResolveServerMethod "addHandler" o = ServerAddHandlerMethodInfo
    ResolveServerMethod "addWebsocketHandler" o = ServerAddWebsocketHandlerMethodInfo
    ResolveServerMethod "bindProperty" o = GObject.Object.ObjectBindPropertyMethodInfo
    ResolveServerMethod "bindPropertyFull" o = GObject.Object.ObjectBindPropertyFullMethodInfo
    ResolveServerMethod "disconnect" o = ServerDisconnectMethodInfo
    ResolveServerMethod "forceFloating" o = GObject.Object.ObjectForceFloatingMethodInfo
    ResolveServerMethod "freezeNotify" o = GObject.Object.ObjectFreezeNotifyMethodInfo
    ResolveServerMethod "isFloating" o = GObject.Object.ObjectIsFloatingMethodInfo
    ResolveServerMethod "isHttps" o = ServerIsHttpsMethodInfo
    ResolveServerMethod "listen" o = ServerListenMethodInfo
    ResolveServerMethod "listenAll" o = ServerListenAllMethodInfo
    ResolveServerMethod "listenFd" o = ServerListenFdMethodInfo
    ResolveServerMethod "listenLocal" o = ServerListenLocalMethodInfo
    ResolveServerMethod "listenSocket" o = ServerListenSocketMethodInfo
    ResolveServerMethod "notify" o = GObject.Object.ObjectNotifyMethodInfo
    ResolveServerMethod "notifyByPspec" o = GObject.Object.ObjectNotifyByPspecMethodInfo
    ResolveServerMethod "pauseMessage" o = ServerPauseMessageMethodInfo
    ResolveServerMethod "quit" o = ServerQuitMethodInfo
    ResolveServerMethod "ref" o = GObject.Object.ObjectRefMethodInfo
    ResolveServerMethod "refSink" o = GObject.Object.ObjectRefSinkMethodInfo
    ResolveServerMethod "removeAuthDomain" o = ServerRemoveAuthDomainMethodInfo
    ResolveServerMethod "removeHandler" o = ServerRemoveHandlerMethodInfo
    ResolveServerMethod "replaceData" o = GObject.Object.ObjectReplaceDataMethodInfo
    ResolveServerMethod "replaceQdata" o = GObject.Object.ObjectReplaceQdataMethodInfo
    ResolveServerMethod "run" o = ServerRunMethodInfo
    ResolveServerMethod "runAsync" o = ServerRunAsyncMethodInfo
    ResolveServerMethod "runDispose" o = GObject.Object.ObjectRunDisposeMethodInfo
    ResolveServerMethod "stealData" o = GObject.Object.ObjectStealDataMethodInfo
    ResolveServerMethod "stealQdata" o = GObject.Object.ObjectStealQdataMethodInfo
    ResolveServerMethod "thawNotify" o = GObject.Object.ObjectThawNotifyMethodInfo
    ResolveServerMethod "unpauseMessage" o = ServerUnpauseMessageMethodInfo
    ResolveServerMethod "unref" o = GObject.Object.ObjectUnrefMethodInfo
    ResolveServerMethod "watchClosure" o = GObject.Object.ObjectWatchClosureMethodInfo
    ResolveServerMethod "getAsyncContext" o = ServerGetAsyncContextMethodInfo
    ResolveServerMethod "getData" o = GObject.Object.ObjectGetDataMethodInfo
    ResolveServerMethod "getListener" o = ServerGetListenerMethodInfo
    ResolveServerMethod "getListeners" o = ServerGetListenersMethodInfo
    ResolveServerMethod "getPort" o = ServerGetPortMethodInfo
    ResolveServerMethod "getProperty" o = GObject.Object.ObjectGetPropertyMethodInfo
    ResolveServerMethod "getQdata" o = GObject.Object.ObjectGetQdataMethodInfo
    ResolveServerMethod "getUris" o = ServerGetUrisMethodInfo
    ResolveServerMethod "setData" o = GObject.Object.ObjectSetDataMethodInfo
    ResolveServerMethod "setProperty" o = GObject.Object.ObjectSetPropertyMethodInfo
    ResolveServerMethod "setSslCertFile" o = ServerSetSslCertFileMethodInfo
    ResolveServerMethod l o = O.MethodResolutionFailed l o

instance (info ~ ResolveServerMethod t Server, O.MethodInfo info Server p) => O.IsLabelProxy t (Server -> p) where
    fromLabelProxy _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)

#if MIN_VERSION_base(4,9,0)
instance (info ~ ResolveServerMethod t Server, O.MethodInfo info Server p) => O.IsLabel t (Server -> p) where
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

-- signal Server::request-aborted
type ServerRequestAbortedCallback =
    Soup.Message.Message ->
    Soup.ClientContext.ClientContext ->
    IO ()

noServerRequestAbortedCallback :: Maybe ServerRequestAbortedCallback
noServerRequestAbortedCallback = Nothing

type C_ServerRequestAbortedCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_ServerRequestAbortedCallback :: C_ServerRequestAbortedCallback -> IO (FunPtr C_ServerRequestAbortedCallback)

genClosure_ServerRequestAborted :: ServerRequestAbortedCallback -> IO Closure
genClosure_ServerRequestAborted cb = do
    let cb' = wrap_ServerRequestAbortedCallback cb
    mk_ServerRequestAbortedCallback cb' >>= newCClosure


wrap_ServerRequestAbortedCallback ::
    ServerRequestAbortedCallback ->
    Ptr () ->
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()
wrap_ServerRequestAbortedCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    client' <- (newBoxed Soup.ClientContext.ClientContext) client
    _cb  message' client'


onServerRequestAborted :: (GObject a, MonadIO m) => a -> ServerRequestAbortedCallback -> m SignalHandlerId
onServerRequestAborted obj cb = liftIO $ connectServerRequestAborted obj cb SignalConnectBefore
afterServerRequestAborted :: (GObject a, MonadIO m) => a -> ServerRequestAbortedCallback -> m SignalHandlerId
afterServerRequestAborted obj cb = connectServerRequestAborted obj cb SignalConnectAfter

connectServerRequestAborted :: (GObject a, MonadIO m) =>
                               a -> ServerRequestAbortedCallback -> SignalConnectMode -> m SignalHandlerId
connectServerRequestAborted obj cb after = liftIO $ do
    let cb' = wrap_ServerRequestAbortedCallback cb
    cb'' <- mk_ServerRequestAbortedCallback cb'
    connectSignalFunPtr obj "request-aborted" cb'' after

-- signal Server::request-finished
type ServerRequestFinishedCallback =
    Soup.Message.Message ->
    Soup.ClientContext.ClientContext ->
    IO ()

noServerRequestFinishedCallback :: Maybe ServerRequestFinishedCallback
noServerRequestFinishedCallback = Nothing

type C_ServerRequestFinishedCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_ServerRequestFinishedCallback :: C_ServerRequestFinishedCallback -> IO (FunPtr C_ServerRequestFinishedCallback)

genClosure_ServerRequestFinished :: ServerRequestFinishedCallback -> IO Closure
genClosure_ServerRequestFinished cb = do
    let cb' = wrap_ServerRequestFinishedCallback cb
    mk_ServerRequestFinishedCallback cb' >>= newCClosure


wrap_ServerRequestFinishedCallback ::
    ServerRequestFinishedCallback ->
    Ptr () ->
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()
wrap_ServerRequestFinishedCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    client' <- (newBoxed Soup.ClientContext.ClientContext) client
    _cb  message' client'


onServerRequestFinished :: (GObject a, MonadIO m) => a -> ServerRequestFinishedCallback -> m SignalHandlerId
onServerRequestFinished obj cb = liftIO $ connectServerRequestFinished obj cb SignalConnectBefore
afterServerRequestFinished :: (GObject a, MonadIO m) => a -> ServerRequestFinishedCallback -> m SignalHandlerId
afterServerRequestFinished obj cb = connectServerRequestFinished obj cb SignalConnectAfter

connectServerRequestFinished :: (GObject a, MonadIO m) =>
                                a -> ServerRequestFinishedCallback -> SignalConnectMode -> m SignalHandlerId
connectServerRequestFinished obj cb after = liftIO $ do
    let cb' = wrap_ServerRequestFinishedCallback cb
    cb'' <- mk_ServerRequestFinishedCallback cb'
    connectSignalFunPtr obj "request-finished" cb'' after

-- signal Server::request-read
type ServerRequestReadCallback =
    Soup.Message.Message ->
    Soup.ClientContext.ClientContext ->
    IO ()

noServerRequestReadCallback :: Maybe ServerRequestReadCallback
noServerRequestReadCallback = Nothing

type C_ServerRequestReadCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_ServerRequestReadCallback :: C_ServerRequestReadCallback -> IO (FunPtr C_ServerRequestReadCallback)

genClosure_ServerRequestRead :: ServerRequestReadCallback -> IO Closure
genClosure_ServerRequestRead cb = do
    let cb' = wrap_ServerRequestReadCallback cb
    mk_ServerRequestReadCallback cb' >>= newCClosure


wrap_ServerRequestReadCallback ::
    ServerRequestReadCallback ->
    Ptr () ->
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()
wrap_ServerRequestReadCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    client' <- (newBoxed Soup.ClientContext.ClientContext) client
    _cb  message' client'


onServerRequestRead :: (GObject a, MonadIO m) => a -> ServerRequestReadCallback -> m SignalHandlerId
onServerRequestRead obj cb = liftIO $ connectServerRequestRead obj cb SignalConnectBefore
afterServerRequestRead :: (GObject a, MonadIO m) => a -> ServerRequestReadCallback -> m SignalHandlerId
afterServerRequestRead obj cb = connectServerRequestRead obj cb SignalConnectAfter

connectServerRequestRead :: (GObject a, MonadIO m) =>
                            a -> ServerRequestReadCallback -> SignalConnectMode -> m SignalHandlerId
connectServerRequestRead obj cb after = liftIO $ do
    let cb' = wrap_ServerRequestReadCallback cb
    cb'' <- mk_ServerRequestReadCallback cb'
    connectSignalFunPtr obj "request-read" cb'' after

-- signal Server::request-started
type ServerRequestStartedCallback =
    Soup.Message.Message ->
    Soup.ClientContext.ClientContext ->
    IO ()

noServerRequestStartedCallback :: Maybe ServerRequestStartedCallback
noServerRequestStartedCallback = Nothing

type C_ServerRequestStartedCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

foreign import ccall "wrapper"
    mk_ServerRequestStartedCallback :: C_ServerRequestStartedCallback -> IO (FunPtr C_ServerRequestStartedCallback)

genClosure_ServerRequestStarted :: ServerRequestStartedCallback -> IO Closure
genClosure_ServerRequestStarted cb = do
    let cb' = wrap_ServerRequestStartedCallback cb
    mk_ServerRequestStartedCallback cb' >>= newCClosure


wrap_ServerRequestStartedCallback ::
    ServerRequestStartedCallback ->
    Ptr () ->
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->
    IO ()
wrap_ServerRequestStartedCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    client' <- (newBoxed Soup.ClientContext.ClientContext) client
    _cb  message' client'


onServerRequestStarted :: (GObject a, MonadIO m) => a -> ServerRequestStartedCallback -> m SignalHandlerId
onServerRequestStarted obj cb = liftIO $ connectServerRequestStarted obj cb SignalConnectBefore
afterServerRequestStarted :: (GObject a, MonadIO m) => a -> ServerRequestStartedCallback -> m SignalHandlerId
afterServerRequestStarted obj cb = connectServerRequestStarted obj cb SignalConnectAfter

connectServerRequestStarted :: (GObject a, MonadIO m) =>
                               a -> ServerRequestStartedCallback -> SignalConnectMode -> m SignalHandlerId
connectServerRequestStarted obj cb after = liftIO $ do
    let cb' = wrap_ServerRequestStartedCallback cb
    cb'' <- mk_ServerRequestStartedCallback cb'
    connectSignalFunPtr obj "request-started" cb'' after

-- VVV Prop "async-context"
   -- Type: TBasicType TPtr
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getServerAsyncContext :: (MonadIO m, IsServer o) => o -> m (Ptr ())
getServerAsyncContext obj = liftIO $ getObjectPropertyPtr obj "async-context"

constructServerAsyncContext :: (IsServer o) => Ptr () -> IO (GValueConstruct o)
constructServerAsyncContext val = constructObjectPropertyPtr "async-context" val

data ServerAsyncContextPropertyInfo
instance AttrInfo ServerAsyncContextPropertyInfo where
    type AttrAllowedOps ServerAsyncContextPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ServerAsyncContextPropertyInfo = (~) (Ptr ())
    type AttrBaseTypeConstraint ServerAsyncContextPropertyInfo = IsServer
    type AttrGetType ServerAsyncContextPropertyInfo = (Ptr ())
    type AttrLabel ServerAsyncContextPropertyInfo = "async-context"
    type AttrOrigin ServerAsyncContextPropertyInfo = Server
    attrGet _ = getServerAsyncContext
    attrSet _ = undefined
    attrConstruct _ = constructServerAsyncContext
    attrClear _ = undefined

-- VVV Prop "http-aliases"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

getServerHttpAliases :: (MonadIO m, IsServer o) => o -> m (Maybe [T.Text])
getServerHttpAliases obj = liftIO $ getObjectPropertyStringArray obj "http-aliases"

setServerHttpAliases :: (MonadIO m, IsServer o) => o -> [T.Text] -> m ()
setServerHttpAliases obj val = liftIO $ setObjectPropertyStringArray obj "http-aliases" (Just val)

constructServerHttpAliases :: (IsServer o) => [T.Text] -> IO (GValueConstruct o)
constructServerHttpAliases val = constructObjectPropertyStringArray "http-aliases" (Just val)

clearServerHttpAliases :: (MonadIO m, IsServer o) => o -> m ()
clearServerHttpAliases obj = liftIO $ setObjectPropertyStringArray obj "http-aliases" (Nothing :: Maybe [T.Text])

data ServerHttpAliasesPropertyInfo
instance AttrInfo ServerHttpAliasesPropertyInfo where
    type AttrAllowedOps ServerHttpAliasesPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ServerHttpAliasesPropertyInfo = (~) [T.Text]
    type AttrBaseTypeConstraint ServerHttpAliasesPropertyInfo = IsServer
    type AttrGetType ServerHttpAliasesPropertyInfo = (Maybe [T.Text])
    type AttrLabel ServerHttpAliasesPropertyInfo = "http-aliases"
    type AttrOrigin ServerHttpAliasesPropertyInfo = Server
    attrGet _ = getServerHttpAliases
    attrSet _ = setServerHttpAliases
    attrConstruct _ = constructServerHttpAliases
    attrClear _ = clearServerHttpAliases

-- VVV Prop "https-aliases"
   -- Type: TCArray True (-1) (-1) (TBasicType TUTF8)
   -- Flags: [PropertyReadable,PropertyWritable]
   -- Nullable: (Nothing,Nothing)

getServerHttpsAliases :: (MonadIO m, IsServer o) => o -> m (Maybe [T.Text])
getServerHttpsAliases obj = liftIO $ getObjectPropertyStringArray obj "https-aliases"

setServerHttpsAliases :: (MonadIO m, IsServer o) => o -> [T.Text] -> m ()
setServerHttpsAliases obj val = liftIO $ setObjectPropertyStringArray obj "https-aliases" (Just val)

constructServerHttpsAliases :: (IsServer o) => [T.Text] -> IO (GValueConstruct o)
constructServerHttpsAliases val = constructObjectPropertyStringArray "https-aliases" (Just val)

clearServerHttpsAliases :: (MonadIO m, IsServer o) => o -> m ()
clearServerHttpsAliases obj = liftIO $ setObjectPropertyStringArray obj "https-aliases" (Nothing :: Maybe [T.Text])

data ServerHttpsAliasesPropertyInfo
instance AttrInfo ServerHttpsAliasesPropertyInfo where
    type AttrAllowedOps ServerHttpsAliasesPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ServerHttpsAliasesPropertyInfo = (~) [T.Text]
    type AttrBaseTypeConstraint ServerHttpsAliasesPropertyInfo = IsServer
    type AttrGetType ServerHttpsAliasesPropertyInfo = (Maybe [T.Text])
    type AttrLabel ServerHttpsAliasesPropertyInfo = "https-aliases"
    type AttrOrigin ServerHttpsAliasesPropertyInfo = Server
    attrGet _ = getServerHttpsAliases
    attrSet _ = setServerHttpsAliases
    attrConstruct _ = constructServerHttpsAliases
    attrClear _ = clearServerHttpsAliases

-- VVV Prop "interface"
   -- Type: TInterface (Name {namespace = "Soup", name = "Address"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getServerInterface :: (MonadIO m, IsServer o) => o -> m (Maybe Soup.Address.Address)
getServerInterface obj = liftIO $ getObjectPropertyObject obj "interface" Soup.Address.Address

constructServerInterface :: (IsServer o, Soup.Address.IsAddress a) => a -> IO (GValueConstruct o)
constructServerInterface val = constructObjectPropertyObject "interface" (Just val)

data ServerInterfacePropertyInfo
instance AttrInfo ServerInterfacePropertyInfo where
    type AttrAllowedOps ServerInterfacePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ServerInterfacePropertyInfo = Soup.Address.IsAddress
    type AttrBaseTypeConstraint ServerInterfacePropertyInfo = IsServer
    type AttrGetType ServerInterfacePropertyInfo = (Maybe Soup.Address.Address)
    type AttrLabel ServerInterfacePropertyInfo = "interface"
    type AttrOrigin ServerInterfacePropertyInfo = Server
    attrGet _ = getServerInterface
    attrSet _ = undefined
    attrConstruct _ = constructServerInterface
    attrClear _ = undefined

-- VVV Prop "port"
   -- Type: TBasicType TUInt
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Just False,Nothing)

getServerPort :: (MonadIO m, IsServer o) => o -> m Word32
getServerPort obj = liftIO $ getObjectPropertyUInt32 obj "port"

constructServerPort :: (IsServer o) => Word32 -> IO (GValueConstruct o)
constructServerPort val = constructObjectPropertyUInt32 "port" val

data ServerPortPropertyInfo
instance AttrInfo ServerPortPropertyInfo where
    type AttrAllowedOps ServerPortPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ServerPortPropertyInfo = (~) Word32
    type AttrBaseTypeConstraint ServerPortPropertyInfo = IsServer
    type AttrGetType ServerPortPropertyInfo = Word32
    type AttrLabel ServerPortPropertyInfo = "port"
    type AttrOrigin ServerPortPropertyInfo = Server
    attrGet _ = getServerPort
    attrSet _ = undefined
    attrConstruct _ = constructServerPort
    attrClear _ = undefined

-- VVV Prop "raw-paths"
   -- Type: TBasicType TBoolean
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getServerRawPaths :: (MonadIO m, IsServer o) => o -> m Bool
getServerRawPaths obj = liftIO $ getObjectPropertyBool obj "raw-paths"

constructServerRawPaths :: (IsServer o) => Bool -> IO (GValueConstruct o)
constructServerRawPaths val = constructObjectPropertyBool "raw-paths" val

data ServerRawPathsPropertyInfo
instance AttrInfo ServerRawPathsPropertyInfo where
    type AttrAllowedOps ServerRawPathsPropertyInfo = '[ 'AttrConstruct, 'AttrGet]
    type AttrSetTypeConstraint ServerRawPathsPropertyInfo = (~) Bool
    type AttrBaseTypeConstraint ServerRawPathsPropertyInfo = IsServer
    type AttrGetType ServerRawPathsPropertyInfo = Bool
    type AttrLabel ServerRawPathsPropertyInfo = "raw-paths"
    type AttrOrigin ServerRawPathsPropertyInfo = Server
    attrGet _ = getServerRawPaths
    attrSet _ = undefined
    attrConstruct _ = constructServerRawPaths
    attrClear _ = undefined

-- VVV Prop "server-header"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstruct]
   -- Nullable: (Nothing,Nothing)

getServerServerHeader :: (MonadIO m, IsServer o) => o -> m (Maybe T.Text)
getServerServerHeader obj = liftIO $ getObjectPropertyString obj "server-header"

setServerServerHeader :: (MonadIO m, IsServer o) => o -> T.Text -> m ()
setServerServerHeader obj val = liftIO $ setObjectPropertyString obj "server-header" (Just val)

constructServerServerHeader :: (IsServer o) => T.Text -> IO (GValueConstruct o)
constructServerServerHeader val = constructObjectPropertyString "server-header" (Just val)

clearServerServerHeader :: (MonadIO m, IsServer o) => o -> m ()
clearServerServerHeader obj = liftIO $ setObjectPropertyString obj "server-header" (Nothing :: Maybe T.Text)

data ServerServerHeaderPropertyInfo
instance AttrInfo ServerServerHeaderPropertyInfo where
    type AttrAllowedOps ServerServerHeaderPropertyInfo = '[ 'AttrSet, 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ServerServerHeaderPropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint ServerServerHeaderPropertyInfo = IsServer
    type AttrGetType ServerServerHeaderPropertyInfo = (Maybe T.Text)
    type AttrLabel ServerServerHeaderPropertyInfo = "server-header"
    type AttrOrigin ServerServerHeaderPropertyInfo = Server
    attrGet _ = getServerServerHeader
    attrSet _ = setServerServerHeader
    attrConstruct _ = constructServerServerHeader
    attrClear _ = clearServerServerHeader

-- VVV Prop "ssl-cert-file"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getServerSslCertFile :: (MonadIO m, IsServer o) => o -> m (Maybe T.Text)
getServerSslCertFile obj = liftIO $ getObjectPropertyString obj "ssl-cert-file"

constructServerSslCertFile :: (IsServer o) => T.Text -> IO (GValueConstruct o)
constructServerSslCertFile val = constructObjectPropertyString "ssl-cert-file" (Just val)

data ServerSslCertFilePropertyInfo
instance AttrInfo ServerSslCertFilePropertyInfo where
    type AttrAllowedOps ServerSslCertFilePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ServerSslCertFilePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint ServerSslCertFilePropertyInfo = IsServer
    type AttrGetType ServerSslCertFilePropertyInfo = (Maybe T.Text)
    type AttrLabel ServerSslCertFilePropertyInfo = "ssl-cert-file"
    type AttrOrigin ServerSslCertFilePropertyInfo = Server
    attrGet _ = getServerSslCertFile
    attrSet _ = undefined
    attrConstruct _ = constructServerSslCertFile
    attrClear _ = undefined

-- VVV Prop "ssl-key-file"
   -- Type: TBasicType TUTF8
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getServerSslKeyFile :: (MonadIO m, IsServer o) => o -> m (Maybe T.Text)
getServerSslKeyFile obj = liftIO $ getObjectPropertyString obj "ssl-key-file"

constructServerSslKeyFile :: (IsServer o) => T.Text -> IO (GValueConstruct o)
constructServerSslKeyFile val = constructObjectPropertyString "ssl-key-file" (Just val)

data ServerSslKeyFilePropertyInfo
instance AttrInfo ServerSslKeyFilePropertyInfo where
    type AttrAllowedOps ServerSslKeyFilePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ServerSslKeyFilePropertyInfo = (~) T.Text
    type AttrBaseTypeConstraint ServerSslKeyFilePropertyInfo = IsServer
    type AttrGetType ServerSslKeyFilePropertyInfo = (Maybe T.Text)
    type AttrLabel ServerSslKeyFilePropertyInfo = "ssl-key-file"
    type AttrOrigin ServerSslKeyFilePropertyInfo = Server
    attrGet _ = getServerSslKeyFile
    attrSet _ = undefined
    attrConstruct _ = constructServerSslKeyFile
    attrClear _ = undefined

-- VVV Prop "tls-certificate"
   -- Type: TInterface (Name {namespace = "Gio", name = "TlsCertificate"})
   -- Flags: [PropertyReadable,PropertyWritable,PropertyConstructOnly]
   -- Nullable: (Nothing,Nothing)

getServerTlsCertificate :: (MonadIO m, IsServer o) => o -> m (Maybe Gio.TlsCertificate.TlsCertificate)
getServerTlsCertificate obj = liftIO $ getObjectPropertyObject obj "tls-certificate" Gio.TlsCertificate.TlsCertificate

constructServerTlsCertificate :: (IsServer o, Gio.TlsCertificate.IsTlsCertificate a) => a -> IO (GValueConstruct o)
constructServerTlsCertificate val = constructObjectPropertyObject "tls-certificate" (Just val)

data ServerTlsCertificatePropertyInfo
instance AttrInfo ServerTlsCertificatePropertyInfo where
    type AttrAllowedOps ServerTlsCertificatePropertyInfo = '[ 'AttrConstruct, 'AttrGet, 'AttrClear]
    type AttrSetTypeConstraint ServerTlsCertificatePropertyInfo = Gio.TlsCertificate.IsTlsCertificate
    type AttrBaseTypeConstraint ServerTlsCertificatePropertyInfo = IsServer
    type AttrGetType ServerTlsCertificatePropertyInfo = (Maybe Gio.TlsCertificate.TlsCertificate)
    type AttrLabel ServerTlsCertificatePropertyInfo = "tls-certificate"
    type AttrOrigin ServerTlsCertificatePropertyInfo = Server
    attrGet _ = getServerTlsCertificate
    attrSet _ = undefined
    attrConstruct _ = constructServerTlsCertificate
    attrClear _ = undefined

instance O.HasAttributeList Server
type instance O.AttributeList Server = ServerAttributeList
type ServerAttributeList = ('[ '("asyncContext", ServerAsyncContextPropertyInfo), '("httpAliases", ServerHttpAliasesPropertyInfo), '("httpsAliases", ServerHttpsAliasesPropertyInfo), '("interface", ServerInterfacePropertyInfo), '("port", ServerPortPropertyInfo), '("rawPaths", ServerRawPathsPropertyInfo), '("serverHeader", ServerServerHeaderPropertyInfo), '("sslCertFile", ServerSslCertFilePropertyInfo), '("sslKeyFile", ServerSslKeyFilePropertyInfo), '("tlsCertificate", ServerTlsCertificatePropertyInfo)] :: [(Symbol, *)])

serverAsyncContext :: AttrLabelProxy "asyncContext"
serverAsyncContext = AttrLabelProxy

serverHttpAliases :: AttrLabelProxy "httpAliases"
serverHttpAliases = AttrLabelProxy

serverHttpsAliases :: AttrLabelProxy "httpsAliases"
serverHttpsAliases = AttrLabelProxy

serverInterface :: AttrLabelProxy "interface"
serverInterface = AttrLabelProxy

serverPort :: AttrLabelProxy "port"
serverPort = AttrLabelProxy

serverRawPaths :: AttrLabelProxy "rawPaths"
serverRawPaths = AttrLabelProxy

serverServerHeader :: AttrLabelProxy "serverHeader"
serverServerHeader = AttrLabelProxy

serverSslCertFile :: AttrLabelProxy "sslCertFile"
serverSslCertFile = AttrLabelProxy

serverSslKeyFile :: AttrLabelProxy "sslKeyFile"
serverSslKeyFile = AttrLabelProxy

serverTlsCertificate :: AttrLabelProxy "tlsCertificate"
serverTlsCertificate = AttrLabelProxy

data ServerRequestAbortedSignalInfo
instance SignalInfo ServerRequestAbortedSignalInfo where
    type HaskellCallbackType ServerRequestAbortedSignalInfo = ServerRequestAbortedCallback
    connectSignal _ = connectServerRequestAborted

data ServerRequestFinishedSignalInfo
instance SignalInfo ServerRequestFinishedSignalInfo where
    type HaskellCallbackType ServerRequestFinishedSignalInfo = ServerRequestFinishedCallback
    connectSignal _ = connectServerRequestFinished

data ServerRequestReadSignalInfo
instance SignalInfo ServerRequestReadSignalInfo where
    type HaskellCallbackType ServerRequestReadSignalInfo = ServerRequestReadCallback
    connectSignal _ = connectServerRequestRead

data ServerRequestStartedSignalInfo
instance SignalInfo ServerRequestStartedSignalInfo where
    type HaskellCallbackType ServerRequestStartedSignalInfo = ServerRequestStartedCallback
    connectSignal _ = connectServerRequestStarted

type instance O.SignalList Server = ServerSignalList
type ServerSignalList = ('[ '("notify", GObject.Object.ObjectNotifySignalInfo), '("requestAborted", ServerRequestAbortedSignalInfo), '("requestFinished", ServerRequestFinishedSignalInfo), '("requestRead", ServerRequestReadSignalInfo), '("requestStarted", ServerRequestStartedSignalInfo)] :: [(Symbol, *)])

-- method Server::accept_iostream
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "stream", argType = TInterface (Name {namespace = "Gio", name = "IOStream"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #GIOStream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "local_addr", argType = TInterface (Name {namespace = "Gio", name = "SocketAddress"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the local #GSocketAddress associated with the @stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "remote_addr", argType = TInterface (Name {namespace = "Gio", name = "SocketAddress"}), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the remote #GSocketAddress associated with the @stream", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_server_accept_iostream" soup_server_accept_iostream :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Ptr Gio.IOStream.IOStream ->            -- stream : TInterface (Name {namespace = "Gio", name = "IOStream"})
    Ptr Gio.SocketAddress.SocketAddress ->  -- local_addr : TInterface (Name {namespace = "Gio", name = "SocketAddress"})
    Ptr Gio.SocketAddress.SocketAddress ->  -- remote_addr : TInterface (Name {namespace = "Gio", name = "SocketAddress"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Add a new client stream to the /@server@/.

@since 2.50
-}
serverAcceptIostream ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a, Gio.IOStream.IsIOStream b, Gio.SocketAddress.IsSocketAddress c, Gio.SocketAddress.IsSocketAddress d) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@stream@/: a 'GI.Gio.Objects.IOStream.IOStream' -}
    -> Maybe (c)
    {- ^ /@localAddr@/: the local 'GI.Gio.Objects.SocketAddress.SocketAddress' associated with the /@stream@/ -}
    -> Maybe (d)
    {- ^ /@remoteAddr@/: the remote 'GI.Gio.Objects.SocketAddress.SocketAddress' associated with the /@stream@/ -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
serverAcceptIostream server stream localAddr remoteAddr = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    stream' <- unsafeManagedPtrCastPtr stream
    maybeLocalAddr <- case localAddr of
        Nothing -> return nullPtr
        Just jLocalAddr -> do
            jLocalAddr' <- unsafeManagedPtrCastPtr jLocalAddr
            return jLocalAddr'
    maybeRemoteAddr <- case remoteAddr of
        Nothing -> return nullPtr
        Just jRemoteAddr -> do
            jRemoteAddr' <- unsafeManagedPtrCastPtr jRemoteAddr
            return jRemoteAddr'
    onException (do
        _ <- propagateGError $ soup_server_accept_iostream server' stream' maybeLocalAddr maybeRemoteAddr
        touchManagedPtr server
        touchManagedPtr stream
        whenJust localAddr touchManagedPtr
        whenJust remoteAddr touchManagedPtr
        return ()
     ) (do
        return ()
     )

data ServerAcceptIostreamMethodInfo
instance (signature ~ (b -> Maybe (c) -> Maybe (d) -> m ()), MonadIO m, IsServer a, Gio.IOStream.IsIOStream b, Gio.SocketAddress.IsSocketAddress c, Gio.SocketAddress.IsSocketAddress d) => O.MethodInfo ServerAcceptIostreamMethodInfo a signature where
    overloadedMethod _ = serverAcceptIostream

-- method Server::add_auth_domain
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth_domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuthDomain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_add_auth_domain" soup_server_add_auth_domain :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Ptr Soup.AuthDomain.AuthDomain ->       -- auth_domain : TInterface (Name {namespace = "Soup", name = "AuthDomain"})
    IO ()

{- |
Adds an authentication domain to /@server@/. Each auth domain will
have the chance to require authentication for each request that
comes in; normally auth domains will require authentication for
requests on certain paths that they have been set up to watch, or
that meet other criteria set by the caller. If an auth domain
determines that a request requires authentication (and the request
doesn\'t contain authentication), /@server@/ will automatically reject
the request with an appropriate status (401 Unauthorized or 407
Proxy Authentication Required). If the request used the
\"100-continue\" Expectation, /@server@/ will reject it before the
request body is sent.
-}
serverAddAuthDomain ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a, Soup.AuthDomain.IsAuthDomain b) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@authDomain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> m ()
serverAddAuthDomain server authDomain = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    authDomain' <- unsafeManagedPtrCastPtr authDomain
    soup_server_add_auth_domain server' authDomain'
    touchManagedPtr server
    touchManagedPtr authDomain
    return ()

data ServerAddAuthDomainMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsServer a, Soup.AuthDomain.IsAuthDomain b) => O.MethodInfo ServerAddAuthDomainMethodInfo a signature where
    overloadedMethod _ = serverAddAuthDomain

-- method Server::add_early_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the toplevel path for the handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Soup", name = "ServerCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "callback to invoke for requests under @path", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data for @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destroy notifier to free @user_data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_add_early_handler" soup_server_add_early_handler :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    CString ->                              -- path : TBasicType TUTF8
    FunPtr Soup.Callbacks.C_ServerCallback -> -- callback : TInterface (Name {namespace = "Soup", name = "ServerCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

{- |
Adds an \"early\" handler to /@server@/ for requests under /@path@/. Note
that \"normal\" and \"early\" handlers are matched up together, so if
you add a normal handler for \"\/foo\" and an early handler for
\"\/foo\/bar\", then a request to \"\/foo\/bar\" (or any path below it)
will run only the early handler. (But if you add both handlers at
the same path, then both will get run.)

For requests under /@path@/ (that have not already been assigned a
status code by a 'GI.Soup.Objects.AuthDomain.AuthDomain' or a signal handler), /@callback@/
will be invoked after receiving the request headers, but before
receiving the request body; the message\'s 'GI.Soup.Objects.Message.Message':@/method/@ and
'GI.Soup.Objects.Message.Message':@/request-headers/@ fields will be filled in.

Early handlers are generally used for processing requests with
request bodies in a streaming fashion. If you determine that the
request will contain a message body, normally you would call
'GI.Soup.Structs.MessageBody.messageBodySetAccumulate' on the message\'s
'GI.Soup.Objects.Message.Message':@/request-body/@ to turn off request-body accumulation,
and connect to the message\'s 'GI.Soup.Objects.Message.Message'::@/got-chunk/@ signal to
process each chunk as it comes in.

To complete the message processing after the full message body has
been read, you can either also connect to 'GI.Soup.Objects.Message.Message'::@/got-body/@,
or else you can register a non-early handler for /@path@/ as well. As
long as you have not set the 'GI.Soup.Objects.Message.Message':@/status-code/@ by the time
'GI.Soup.Objects.Message.Message'::@/got-body/@ is emitted, the non-early handler will be
run as well.

@since 2.50
-}
serverAddEarlyHandler ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> Maybe (T.Text)
    {- ^ /@path@/: the toplevel path for the handler -}
    -> Soup.Callbacks.ServerCallback
    {- ^ /@callback@/: callback to invoke for requests under /@path@/ -}
    -> m ()
serverAddEarlyHandler server path callback = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    maybePath <- case path of
        Nothing -> return nullPtr
        Just jPath -> do
            jPath' <- textToCString jPath
            return jPath'
    callback' <- Soup.Callbacks.mk_ServerCallback (Soup.Callbacks.wrap_ServerCallback Nothing (Soup.Callbacks.drop_closures_ServerCallback callback))
    let userData = castFunPtrToPtr callback'
    let destroy = safeFreeFunPtrPtr
    soup_server_add_early_handler server' maybePath callback' userData destroy
    touchManagedPtr server
    freeMem maybePath
    return ()

data ServerAddEarlyHandlerMethodInfo
instance (signature ~ (Maybe (T.Text) -> Soup.Callbacks.ServerCallback -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerAddEarlyHandlerMethodInfo a signature where
    overloadedMethod _ = serverAddEarlyHandler

-- method Server::add_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the toplevel path for the handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Soup", name = "ServerCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "callback to invoke for requests under @path", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 3, argDestroy = 4, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data for @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destroy notifier to free @user_data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_add_handler" soup_server_add_handler :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    CString ->                              -- path : TBasicType TUTF8
    FunPtr Soup.Callbacks.C_ServerCallback -> -- callback : TInterface (Name {namespace = "Soup", name = "ServerCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

{- |
Adds a handler to /@server@/ for requests under /@path@/. If /@path@/ is
'Nothing' or \"\/\", then this will be the default handler for all
requests that don\'t have a more specific handler. (Note though that
if you want to handle requests to the special \"*\" URI, you must
explicitly register a handler for \"*\"; the default handler will not
be used for that case.)

For requests under /@path@/ (that have not already been assigned a
status code by a 'GI.Soup.Objects.AuthDomain.AuthDomain', an early @/SoupServerHandler/@, or a
signal handler), /@callback@/ will be invoked after receiving the
request body; the message\'s 'GI.Soup.Objects.Message.Message':@/method/@,
'GI.Soup.Objects.Message.Message':@/request-headers/@, and 'GI.Soup.Objects.Message.Message':@/request-body/@ fields
will be filled in.

After determining what to do with the request, the callback must at
a minimum call 'GI.Soup.Objects.Message.messageSetStatus' (or
'GI.Soup.Objects.Message.messageSetStatusFull') on the message to set the response
status code. Additionally, it may set response headers and\/or fill
in the response body.

If the callback cannot fully fill in the response before returning
(eg, if it needs to wait for information from a database, or
another network server), it should call 'GI.Soup.Objects.Server.serverPauseMessage'
to tell /@server@/ to not send the response right away. When the
response is ready, call 'GI.Soup.Objects.Server.serverUnpauseMessage' to cause it
to be sent.

To send the response body a bit at a time using \"chunked\" encoding,
first call 'GI.Soup.Structs.MessageHeaders.messageHeadersSetEncoding' to set
'GI.Soup.Enums.EncodingChunked' on the 'GI.Soup.Objects.Message.Message':@/response-headers/@. Then call
@/soup_message_body_append()/@ (or 'GI.Soup.Structs.MessageBody.messageBodyAppendBuffer')
to append each chunk as it becomes ready, and
'GI.Soup.Objects.Server.serverUnpauseMessage' to make sure it\'s running. (The
server will automatically pause the message if it is using chunked
encoding but no more chunks are available.) When you are done, call
'GI.Soup.Structs.MessageBody.messageBodyComplete' to indicate that no more chunks are
coming.
-}
serverAddHandler ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> Maybe (T.Text)
    {- ^ /@path@/: the toplevel path for the handler -}
    -> Soup.Callbacks.ServerCallback
    {- ^ /@callback@/: callback to invoke for requests under /@path@/ -}
    -> m ()
serverAddHandler server path callback = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    maybePath <- case path of
        Nothing -> return nullPtr
        Just jPath -> do
            jPath' <- textToCString jPath
            return jPath'
    callback' <- Soup.Callbacks.mk_ServerCallback (Soup.Callbacks.wrap_ServerCallback Nothing (Soup.Callbacks.drop_closures_ServerCallback callback))
    let userData = castFunPtrToPtr callback'
    let destroy = safeFreeFunPtrPtr
    soup_server_add_handler server' maybePath callback' userData destroy
    touchManagedPtr server
    freeMem maybePath
    return ()

data ServerAddHandlerMethodInfo
instance (signature ~ (Maybe (T.Text) -> Soup.Callbacks.ServerCallback -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerAddHandlerMethodInfo a signature where
    overloadedMethod _ = serverAddHandler

-- method Server::add_websocket_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the toplevel path for the handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "origin", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the origin of the connection", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "protocols", argType = TCArray True (-1) (-1) (TBasicType TUTF8), direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "the protocols\n  supported by this handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "callback", argType = TInterface (Name {namespace = "Soup", name = "ServerWebsocketCallback"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "callback to invoke for successful WebSocket requests under @path", sinceVersion = Nothing}, argScope = ScopeTypeNotified, argClosure = 5, argDestroy = 6, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "user_data", argType = TBasicType TPtr, direction = DirectionIn, mayBeNull = True, argDoc = Documentation {rawDocText = Just "data for @callback", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "destroy", argType = TInterface (Name {namespace = "GLib", name = "DestroyNotify"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "destroy notifier to free @user_data", sinceVersion = Nothing}, argScope = ScopeTypeAsync, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_add_websocket_handler" soup_server_add_websocket_handler :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    CString ->                              -- path : TBasicType TUTF8
    CString ->                              -- origin : TBasicType TUTF8
    Ptr CString ->                          -- protocols : TCArray True (-1) (-1) (TBasicType TUTF8)
    FunPtr Soup.Callbacks.C_ServerWebsocketCallback -> -- callback : TInterface (Name {namespace = "Soup", name = "ServerWebsocketCallback"})
    Ptr () ->                               -- user_data : TBasicType TPtr
    FunPtr GLib.Callbacks.C_DestroyNotify -> -- destroy : TInterface (Name {namespace = "GLib", name = "DestroyNotify"})
    IO ()

{- |
Adds a WebSocket handler to /@server@/ for requests under /@path@/. (If
/@path@/ is 'Nothing' or \"\/\", then this will be the default handler for
all requests that don\'t have a more specific handler.)

When a path has a WebSocket handler registered, /@server@/ will check
incoming requests for WebSocket handshakes after all other handlers
have run (unless some earlier handler has already set a status code
on the message), and update the request\'s status, response headers,
and response body accordingly.

If /@origin@/ is non-'Nothing', then only requests containing a matching
\"Origin\" header will be accepted. If /@protocols@/ is non-'Nothing', then
only requests containing a compatible \"Sec-WebSocket-Protocols\"
header will be accepted. More complicated requirements can be
handled by adding a normal handler to /@path@/, and having it perform
whatever checks are needed (possibly calling
@/soup_server_check_websocket_handshake()/@ one or more times), and
setting a failure status code if the handshake should be rejected.
-}
serverAddWebsocketHandler ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> Maybe (T.Text)
    {- ^ /@path@/: the toplevel path for the handler -}
    -> Maybe (T.Text)
    {- ^ /@origin@/: the origin of the connection -}
    -> Maybe ([T.Text])
    {- ^ /@protocols@/: the protocols
  supported by this handler -}
    -> Soup.Callbacks.ServerWebsocketCallback
    {- ^ /@callback@/: callback to invoke for successful WebSocket requests under /@path@/ -}
    -> m ()
serverAddWebsocketHandler server path origin protocols callback = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    maybePath <- case path of
        Nothing -> return nullPtr
        Just jPath -> do
            jPath' <- textToCString jPath
            return jPath'
    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'
    callback' <- Soup.Callbacks.mk_ServerWebsocketCallback (Soup.Callbacks.wrap_ServerWebsocketCallback Nothing (Soup.Callbacks.drop_closures_ServerWebsocketCallback callback))
    let userData = castFunPtrToPtr callback'
    let destroy = safeFreeFunPtrPtr
    soup_server_add_websocket_handler server' maybePath maybeOrigin maybeProtocols callback' userData destroy
    touchManagedPtr server
    freeMem maybePath
    freeMem maybeOrigin
    mapZeroTerminatedCArray freeMem maybeProtocols
    freeMem maybeProtocols
    return ()

data ServerAddWebsocketHandlerMethodInfo
instance (signature ~ (Maybe (T.Text) -> Maybe (T.Text) -> Maybe ([T.Text]) -> Soup.Callbacks.ServerWebsocketCallback -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerAddWebsocketHandlerMethodInfo a signature where
    overloadedMethod _ = serverAddWebsocketHandler

-- method Server::disconnect
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_disconnect" soup_server_disconnect :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO ()

{- |
Closes and frees /@server@/\'s listening sockets. If you are using the
old 'GI.Soup.Objects.Server.Server' APIs, this also includes the effect of
'GI.Soup.Objects.Server.serverQuit'.

Note that if there are currently requests in progress on /@server@/,
that they will continue to be processed if /@server@/\'s 'GI.GLib.Structs.MainContext.MainContext'
is still running.

You can call 'GI.Soup.Objects.Server.serverListen', etc, after calling this function
if you want to start listening again.
-}
serverDisconnect ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m ()
serverDisconnect server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    soup_server_disconnect server'
    touchManagedPtr server
    return ()

data ServerDisconnectMethodInfo
instance (signature ~ (m ()), MonadIO m, IsServer a) => O.MethodInfo ServerDisconnectMethodInfo a signature where
    overloadedMethod _ = serverDisconnect

-- method Server::get_async_context
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "GLib", name = "MainContext"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_get_async_context" soup_server_get_async_context :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO (Ptr GLib.MainContext.MainContext)

{-# DEPRECATED serverGetAsyncContext ["If you are using 'GI.Soup.Objects.Server.serverListen', etc, then","the server listens on the thread-default 'GI.GLib.Structs.MainContext.MainContext', and this","property is ignored."] #-}
{- |
Gets /@server@/\'s async_context, if you are using the old API. (With
the new API, the server runs in the thread\'s thread-default
'GI.GLib.Structs.MainContext.MainContext', regardless of what this method returns.)

This does not add a ref to the context, so you will need to ref it
yourself if you want it to outlive its server.
-}
serverGetAsyncContext ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m (Maybe GLib.MainContext.MainContext)
    {- ^ __Returns:__ /@server@/\'s 'GI.GLib.Structs.MainContext.MainContext',
which may be 'Nothing' -}
serverGetAsyncContext server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    result <- soup_server_get_async_context server'
    maybeResult <- convertIfNonNull result $ \result' -> do
        result'' <- (newBoxed GLib.MainContext.MainContext) result'
        return result''
    touchManagedPtr server
    return maybeResult

data ServerGetAsyncContextMethodInfo
instance (signature ~ (m (Maybe GLib.MainContext.MainContext)), MonadIO m, IsServer a) => O.MethodInfo ServerGetAsyncContextMethodInfo a signature where
    overloadedMethod _ = serverGetAsyncContext

-- method Server::get_listener
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TInterface (Name {namespace = "Soup", name = "Socket"}))
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_get_listener" soup_server_get_listener :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO (Ptr Soup.Socket.Socket)

{-# DEPRECATED serverGetListener ["If you are using 'GI.Soup.Objects.Server.serverListen', etc, then use","'GI.Soup.Objects.Server.serverGetListeners' to get a list of all listening sockets,","but note that that function returns @/GSockets/@, not @/SoupSockets/@."] #-}
{- |
Gets /@server@/\'s listening socket, if you are using the old API.

You should treat this socket as read-only; writing to it or
modifiying it may cause /@server@/ to malfunction.
-}
serverGetListener ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m Soup.Socket.Socket
    {- ^ __Returns:__ the listening socket. -}
serverGetListener server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    result <- soup_server_get_listener server'
    checkUnexpectedReturnNULL "serverGetListener" result
    result' <- (newObject Soup.Socket.Socket) result
    touchManagedPtr server
    return result'

data ServerGetListenerMethodInfo
instance (signature ~ (m Soup.Socket.Socket), MonadIO m, IsServer a) => O.MethodInfo ServerGetListenerMethodInfo a signature where
    overloadedMethod _ = serverGetListener

-- method Server::get_listeners
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGSList (TInterface (Name {namespace = "Gio", name = "Socket"})))
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_get_listeners" soup_server_get_listeners :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO (Ptr (GSList (Ptr Gio.Socket.Socket)))

{- |
Gets /@server@/\'s list of listening sockets.

You should treat these sockets as read-only; writing to or
modifiying any of these sockets may cause /@server@/ to malfunction.

(Beware that in contrast to the old 'GI.Soup.Objects.Server.serverGetListener', this
function returns @/GSockets/@, not @/SoupSockets/@.)
-}
serverGetListeners ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m [Gio.Socket.Socket]
    {- ^ __Returns:__ a
list of listening sockets. -}
serverGetListeners server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    result <- soup_server_get_listeners server'
    result' <- unpackGSList result
    result'' <- mapM (newObject Gio.Socket.Socket) result'
    g_slist_free result
    touchManagedPtr server
    return result''

data ServerGetListenersMethodInfo
instance (signature ~ (m [Gio.Socket.Socket]), MonadIO m, IsServer a) => O.MethodInfo ServerGetListenersMethodInfo a signature where
    overloadedMethod _ = serverGetListeners

-- method Server::get_port
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TUInt)
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_get_port" soup_server_get_port :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO Word32

{-# DEPRECATED serverGetPort ["If you are using 'GI.Soup.Objects.Server.serverListen', etc, then use","'GI.Soup.Objects.Server.serverGetUris' to get a list of all listening addresses."] #-}
{- |
Gets the TCP port that /@server@/ is listening on, if you are using
the old API.
-}
serverGetPort ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m Word32
    {- ^ __Returns:__ the port /@server@/ is listening on. -}
serverGetPort server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    result <- soup_server_get_port server'
    touchManagedPtr server
    return result

data ServerGetPortMethodInfo
instance (signature ~ (m Word32), MonadIO m, IsServer a) => O.MethodInfo ServerGetPortMethodInfo a signature where
    overloadedMethod _ = serverGetPort

-- method Server::get_uris
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TGSList (TInterface (Name {namespace = "Soup", name = "URI"})))
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_get_uris" soup_server_get_uris :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO (Ptr (GSList (Ptr Soup.URI.URI)))

{- |
Gets a list of URIs corresponding to the interfaces /@server@/ is
listening on. These will contain IP addresses, not hostnames, and
will also indicate whether the given listener is http or https.

Note that if you used 'GI.Soup.Objects.Server.serverListenAll', the returned URIs
will use the addresses \<literal>0.0.0.0\<\/literal> and
\<literal>::\<\/literal>, rather than actually returning separate URIs
for each interface on the system.

@since 2.48
-}
serverGetUris ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m [Soup.URI.URI]
    {- ^ __Returns:__ a list of
@/SoupURIs/@, which you must free when you are done with it. -}
serverGetUris server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    result <- soup_server_get_uris server'
    result' <- unpackGSList result
    result'' <- mapM (wrapBoxed Soup.URI.URI) result'
    g_slist_free result
    touchManagedPtr server
    return result''

data ServerGetUrisMethodInfo
instance (signature ~ (m [Soup.URI.URI]), MonadIO m, IsServer a) => O.MethodInfo ServerGetUrisMethodInfo a signature where
    overloadedMethod _ = serverGetUris

-- method Server::is_https
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_is_https" soup_server_is_https :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO CInt

{- |
Checks whether /@server@/ is capable of https.

In order for a server to run https, you must call
'GI.Soup.Objects.Server.serverSetSslCertFile', or set the
'GI.Soup.Objects.Server.Server':@/tls-certificate/@ property, to provide it with a
certificate to use.

If you are using the deprecated single-listener APIs, then a return
value of 'True' indicates that the 'GI.Soup.Objects.Server.Server' serves https
exclusively. If you are using 'GI.Soup.Objects.Server.serverListen', etc, then a
'True' return value merely indicates that the server is
\<emphasis>able\<\/emphasis> to do https, regardless of whether it
actually currently is or not. Use 'GI.Soup.Objects.Server.serverGetUris' to see if
it currently has any https listeners.
-}
serverIsHttps ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m Bool
    {- ^ __Returns:__ 'True' if /@server@/ is configured to serve https. -}
serverIsHttps server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    result <- soup_server_is_https server'
    let result' = (/= 0) result
    touchManagedPtr server
    return result'

data ServerIsHttpsMethodInfo
instance (signature ~ (m Bool), MonadIO m, IsServer a) => O.MethodInfo ServerIsHttpsMethodInfo a signature where
    overloadedMethod _ = serverIsHttps

-- method Server::listen
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "address", argType = TInterface (Name {namespace = "Gio", name = "SocketAddress"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the address of the interface to listen on", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Soup", name = "ServerListenOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "listening options for this server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_server_listen" soup_server_listen :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Ptr Gio.SocketAddress.SocketAddress ->  -- address : TInterface (Name {namespace = "Gio", name = "SocketAddress"})
    CUInt ->                                -- options : TInterface (Name {namespace = "Soup", name = "ServerListenOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
This attempts to set up /@server@/ to listen for connections on
/@address@/.

If /@options@/ includes 'GI.Soup.Flags.ServerListenOptionsHttps', and /@server@/ has
been configured for TLS, then /@server@/ will listen for https
connections on this port. Otherwise it will listen for plain http.

You may call this method (along with the other \"listen\" methods)
any number of times on a server, if you want to listen on multiple
ports, or set up both http and https service.

After calling this method, /@server@/ will begin accepting and
processing connections as soon as the appropriate 'GI.GLib.Structs.MainContext.MainContext' is
run.

Note that 'GI.Soup.Objects.Server.Server' never makes use of dual IPv4\/IPv6 sockets; if
/@address@/ is an IPv6 address, it will only accept IPv6 connections.
You must configure IPv4 listening separately.

@since 2.48
-}
serverListen ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a, Gio.SocketAddress.IsSocketAddress b) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@address@/: the address of the interface to listen on -}
    -> [Soup.Flags.ServerListenOptions]
    {- ^ /@options@/: listening options for this server -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
serverListen server address options = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    address' <- unsafeManagedPtrCastPtr address
    let options' = gflagsToWord options
    onException (do
        _ <- propagateGError $ soup_server_listen server' address' options'
        touchManagedPtr server
        touchManagedPtr address
        return ()
     ) (do
        return ()
     )

data ServerListenMethodInfo
instance (signature ~ (b -> [Soup.Flags.ServerListenOptions] -> m ()), MonadIO m, IsServer a, Gio.SocketAddress.IsSocketAddress b) => O.MethodInfo ServerListenMethodInfo a signature where
    overloadedMethod _ = serverListen

-- method Server::listen_all
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "port", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the port to listen on, or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Soup", name = "ServerListenOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "listening options for this server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_server_listen_all" soup_server_listen_all :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Word32 ->                               -- port : TBasicType TUInt
    CUInt ->                                -- options : TInterface (Name {namespace = "Soup", name = "ServerListenOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
This attempts to set up /@server@/ to listen for connections on all
interfaces on the system. (That is, it listens on the addresses
\<literal>0.0.0.0\<\/literal> and\/or \<literal>::\<\/literal>, depending
on whether /@options@/ includes 'GI.Soup.Flags.ServerListenOptionsIpv4Only',
'GI.Soup.Flags.ServerListenOptionsIpv6Only', or neither.) If /@port@/ is specified,
/@server@/ will listen on that port. If it is 0, /@server@/ will find an
unused port to listen on. (In that case, you can use
'GI.Soup.Objects.Server.serverGetUris' to find out what port it ended up choosing.)

See 'GI.Soup.Objects.Server.serverListen' for more details.

@since 2.48
-}
serverListenAll ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> Word32
    {- ^ /@port@/: the port to listen on, or 0 -}
    -> [Soup.Flags.ServerListenOptions]
    {- ^ /@options@/: listening options for this server -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
serverListenAll server port options = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    let options' = gflagsToWord options
    onException (do
        _ <- propagateGError $ soup_server_listen_all server' port options'
        touchManagedPtr server
        return ()
     ) (do
        return ()
     )

data ServerListenAllMethodInfo
instance (signature ~ (Word32 -> [Soup.Flags.ServerListenOptions] -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerListenAllMethodInfo a signature where
    overloadedMethod _ = serverListenAll

-- method Server::listen_fd
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "fd", argType = TBasicType TInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the file descriptor of a listening socket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Soup", name = "ServerListenOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "listening options for this server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_server_listen_fd" soup_server_listen_fd :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Int32 ->                                -- fd : TBasicType TInt
    CUInt ->                                -- options : TInterface (Name {namespace = "Soup", name = "ServerListenOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
This attempts to set up /@server@/ to listen for connections on
/@fd@/.

See 'GI.Soup.Objects.Server.serverListen' for more details.

Note that /@server@/ will close /@fd@/ when you free it or call
'GI.Soup.Objects.Server.serverDisconnect'.

@since 2.48
-}
serverListenFd ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> Int32
    {- ^ /@fd@/: the file descriptor of a listening socket -}
    -> [Soup.Flags.ServerListenOptions]
    {- ^ /@options@/: listening options for this server -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
serverListenFd server fd options = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    let options' = gflagsToWord options
    onException (do
        _ <- propagateGError $ soup_server_listen_fd server' fd options'
        touchManagedPtr server
        return ()
     ) (do
        return ()
     )

data ServerListenFdMethodInfo
instance (signature ~ (Int32 -> [Soup.Flags.ServerListenOptions] -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerListenFdMethodInfo a signature where
    overloadedMethod _ = serverListenFd

-- method Server::listen_local
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "port", argType = TBasicType TUInt, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the port to listen on, or 0", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Soup", name = "ServerListenOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "listening options for this server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_server_listen_local" soup_server_listen_local :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Word32 ->                               -- port : TBasicType TUInt
    CUInt ->                                -- options : TInterface (Name {namespace = "Soup", name = "ServerListenOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
This attempts to set up /@server@/ to listen for connections on
\"localhost\" (that is, \<literal>127.0.0.1\<\/literal> and\/or
\<literal>::1\<\/literal>, depending on whether /@options@/ includes
'GI.Soup.Flags.ServerListenOptionsIpv4Only', 'GI.Soup.Flags.ServerListenOptionsIpv6Only', or
neither). If /@port@/ is specified, /@server@/ will listen on that port.
If it is 0, /@server@/ will find an unused port to listen on. (In that
case, you can use 'GI.Soup.Objects.Server.serverGetUris' to find out what port it
ended up choosing.)

See 'GI.Soup.Objects.Server.serverListen' for more details.

@since 2.48
-}
serverListenLocal ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> Word32
    {- ^ /@port@/: the port to listen on, or 0 -}
    -> [Soup.Flags.ServerListenOptions]
    {- ^ /@options@/: listening options for this server -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
serverListenLocal server port options = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    let options' = gflagsToWord options
    onException (do
        _ <- propagateGError $ soup_server_listen_local server' port options'
        touchManagedPtr server
        return ()
     ) (do
        return ()
     )

data ServerListenLocalMethodInfo
instance (signature ~ (Word32 -> [Soup.Flags.ServerListenOptions] -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerListenLocalMethodInfo a signature where
    overloadedMethod _ = serverListenLocal

-- method Server::listen_socket
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "socket", argType = TInterface (Name {namespace = "Gio", name = "Socket"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a listening #GSocket", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "options", argType = TInterface (Name {namespace = "Soup", name = "ServerListenOptions"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "listening options for this server", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_server_listen_socket" soup_server_listen_socket :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Ptr Gio.Socket.Socket ->                -- socket : TInterface (Name {namespace = "Gio", name = "Socket"})
    CUInt ->                                -- options : TInterface (Name {namespace = "Soup", name = "ServerListenOptions"})
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
This attempts to set up /@server@/ to listen for connections on
/@socket@/.

See 'GI.Soup.Objects.Server.serverListen' for more details.

@since 2.48
-}
serverListenSocket ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a, Gio.Socket.IsSocket b) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@socket@/: a listening 'GI.Gio.Objects.Socket.Socket' -}
    -> [Soup.Flags.ServerListenOptions]
    {- ^ /@options@/: listening options for this server -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
serverListenSocket server socket options = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    socket' <- unsafeManagedPtrCastPtr socket
    let options' = gflagsToWord options
    onException (do
        _ <- propagateGError $ soup_server_listen_socket server' socket' options'
        touchManagedPtr server
        touchManagedPtr socket
        return ()
     ) (do
        return ()
     )

data ServerListenSocketMethodInfo
instance (signature ~ (b -> [Soup.Flags.ServerListenOptions] -> m ()), MonadIO m, IsServer a, Gio.Socket.IsSocket b) => O.MethodInfo ServerListenSocketMethodInfo a signature where
    overloadedMethod _ = serverListenSocket

-- method Server::pause_message
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessage associated with @server.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_pause_message" soup_server_pause_message :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO ()

{- |
Pauses I\/O on /@msg@/. This can be used when you need to return from
the server handler without having the full response ready yet. Use
'GI.Soup.Objects.Server.serverUnpauseMessage' to resume I\/O.

This must only be called on @/SoupMessages/@ which were created by the
'GI.Soup.Objects.Server.Server' and are currently doing I\/O, such as those passed into a
'GI.Soup.Callbacks.ServerCallback' or emitted in a 'GI.Soup.Objects.Server.Server'::@/request-read/@ signal.
-}
serverPauseMessage ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a, Soup.Message.IsMessage b) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@msg@/: a 'GI.Soup.Objects.Message.Message' associated with /@server@/. -}
    -> m ()
serverPauseMessage server msg = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    msg' <- unsafeManagedPtrCastPtr msg
    soup_server_pause_message server' msg'
    touchManagedPtr server
    touchManagedPtr msg
    return ()

data ServerPauseMessageMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsServer a, Soup.Message.IsMessage b) => O.MethodInfo ServerPauseMessageMethodInfo a signature where
    overloadedMethod _ = serverPauseMessage

-- method Server::quit
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_quit" soup_server_quit :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO ()

{-# DEPRECATED serverQuit ["When using 'GI.Soup.Objects.Server.serverListen', etc, the server will","always listen for connections, and will process them whenever the","thread-default 'GI.GLib.Structs.MainContext.MainContext' is running."] #-}
{- |
Stops processing for /@server@/, if you are using the old API. Call
this to clean up after 'GI.Soup.Objects.Server.serverRunAsync', or to terminate a
call to 'GI.Soup.Objects.Server.serverRun'.

Note that messages currently in progress will continue to be
handled, if the main loop associated with the server is resumed or
kept running.

/@server@/ is still in a working state after this call; you can start
and stop a server as many times as you want.
-}
serverQuit ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m ()
serverQuit server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    soup_server_quit server'
    touchManagedPtr server
    return ()

data ServerQuitMethodInfo
instance (signature ~ (m ()), MonadIO m, IsServer a) => O.MethodInfo ServerQuitMethodInfo a signature where
    overloadedMethod _ = serverQuit

-- method Server::remove_auth_domain
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "auth_domain", argType = TInterface (Name {namespace = "Soup", name = "AuthDomain"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupAuthDomain", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_remove_auth_domain" soup_server_remove_auth_domain :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Ptr Soup.AuthDomain.AuthDomain ->       -- auth_domain : TInterface (Name {namespace = "Soup", name = "AuthDomain"})
    IO ()

{- |
Removes /@authDomain@/ from /@server@/.
-}
serverRemoveAuthDomain ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a, Soup.AuthDomain.IsAuthDomain b) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@authDomain@/: a 'GI.Soup.Objects.AuthDomain.AuthDomain' -}
    -> m ()
serverRemoveAuthDomain server authDomain = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    authDomain' <- unsafeManagedPtrCastPtr authDomain
    soup_server_remove_auth_domain server' authDomain'
    touchManagedPtr server
    touchManagedPtr authDomain
    return ()

data ServerRemoveAuthDomainMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsServer a, Soup.AuthDomain.IsAuthDomain b) => O.MethodInfo ServerRemoveAuthDomainMethodInfo a signature where
    overloadedMethod _ = serverRemoveAuthDomain

-- method Server::remove_handler
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "path", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "the toplevel path for the handler", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_remove_handler" soup_server_remove_handler :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    CString ->                              -- path : TBasicType TUTF8
    IO ()

{- |
Removes all handlers (early and normal) registered at /@path@/.
-}
serverRemoveHandler ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> T.Text
    {- ^ /@path@/: the toplevel path for the handler -}
    -> m ()
serverRemoveHandler server path = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    path' <- textToCString path
    soup_server_remove_handler server' path'
    touchManagedPtr server
    freeMem path'
    return ()

data ServerRemoveHandlerMethodInfo
instance (signature ~ (T.Text -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerRemoveHandlerMethodInfo a signature where
    overloadedMethod _ = serverRemoveHandler

-- method Server::run
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_run" soup_server_run :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO ()

{-# DEPRECATED serverRun ["When using 'GI.Soup.Objects.Server.serverListen', etc, the server will","always listen for connections, and will process them whenever the","thread-default 'GI.GLib.Structs.MainContext.MainContext' is running."] #-}
{- |
Starts /@server@/, if you are using the old API, causing it to listen
for and process incoming connections. Unlike
'GI.Soup.Objects.Server.serverRunAsync', this creates a 'GI.GLib.Structs.MainLoop.MainLoop' and runs it, and
it will not return until someone calls 'GI.Soup.Objects.Server.serverQuit' to stop
the server.
-}
serverRun ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m ()
serverRun server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    soup_server_run server'
    touchManagedPtr server
    return ()

data ServerRunMethodInfo
instance (signature ~ (m ()), MonadIO m, IsServer a) => O.MethodInfo ServerRunMethodInfo a signature where
    overloadedMethod _ = serverRun

-- method Server::run_async
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_run_async" soup_server_run_async :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    IO ()

{-# DEPRECATED serverRunAsync ["When using 'GI.Soup.Objects.Server.serverListen', etc, the server will","always listen for connections, and will process them whenever the","thread-default 'GI.GLib.Structs.MainContext.MainContext' is running."] #-}
{- |
Starts /@server@/, if you are using the old API, causing it to listen
for and process incoming connections.

The server runs in /@server@/\'s 'GI.GLib.Structs.MainContext.MainContext'. It will not actually
perform any processing unless the appropriate main loop is running.
In the simple case where you did not set the server\'s
'GI.Soup.Constants.SERVER_ASYNC_CONTEXT' property, this means the server will run
whenever the glib main loop is running.
-}
serverRunAsync ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> m ()
serverRunAsync server = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    soup_server_run_async server'
    touchManagedPtr server
    return ()

data ServerRunAsyncMethodInfo
instance (signature ~ (m ()), MonadIO m, IsServer a) => O.MethodInfo ServerRunAsyncMethodInfo a signature where
    overloadedMethod _ = serverRunAsync

-- method Server::set_ssl_cert_file
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ssl_cert_file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "path to a file containing a PEM-encoded SSL/TLS\n  certificate.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "ssl_key_file", argType = TBasicType TUTF8, direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "path to a file containing a PEM-encoded private key.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Just (TBasicType TBoolean)
-- throws : True
-- Skip return : False

foreign import ccall "soup_server_set_ssl_cert_file" soup_server_set_ssl_cert_file :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    CString ->                              -- ssl_cert_file : TBasicType TUTF8
    CString ->                              -- ssl_key_file : TBasicType TUTF8
    Ptr (Ptr GError) ->                     -- error
    IO CInt

{- |
Sets /@server@/ up to do https, using the SSL\/TLS certificate
specified by /@sslCertFile@/ and /@sslKeyFile@/ (which may point to
the same file).

Alternatively, you can set the 'GI.Soup.Objects.Server.Server':@/tls-certificate/@ property
at construction time, if you already have a 'GI.Gio.Objects.TlsCertificate.TlsCertificate'.

@since 2.48
-}
serverSetSslCertFile ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> T.Text
    {- ^ /@sslCertFile@/: path to a file containing a PEM-encoded SSL\/TLS
  certificate. -}
    -> T.Text
    {- ^ /@sslKeyFile@/: path to a file containing a PEM-encoded private key. -}
    -> m ()
    {- ^ /(Can throw 'Data.GI.Base.GError.GError')/ -}
serverSetSslCertFile server sslCertFile sslKeyFile = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    sslCertFile' <- textToCString sslCertFile
    sslKeyFile' <- textToCString sslKeyFile
    onException (do
        _ <- propagateGError $ soup_server_set_ssl_cert_file server' sslCertFile' sslKeyFile'
        touchManagedPtr server
        freeMem sslCertFile'
        freeMem sslKeyFile'
        return ()
     ) (do
        freeMem sslCertFile'
        freeMem sslKeyFile'
     )

data ServerSetSslCertFileMethodInfo
instance (signature ~ (T.Text -> T.Text -> m ()), MonadIO m, IsServer a) => O.MethodInfo ServerSetSslCertFileMethodInfo a signature where
    overloadedMethod _ = serverSetSslCertFile

-- method Server::unpause_message
-- method type : OrdinaryMethod
-- Args : [Arg {argCName = "server", argType = TInterface (Name {namespace = "Soup", name = "Server"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupServer", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing},Arg {argCName = "msg", argType = TInterface (Name {namespace = "Soup", name = "Message"}), direction = DirectionIn, mayBeNull = False, argDoc = Documentation {rawDocText = Just "a #SoupMessage associated with @server.", sinceVersion = Nothing}, argScope = ScopeTypeInvalid, argClosure = -1, argDestroy = -1, argCallerAllocates = False, transfer = TransferNothing}]
-- Lengths : []
-- returnType : Nothing
-- throws : False
-- Skip return : False

foreign import ccall "soup_server_unpause_message" soup_server_unpause_message :: 
    Ptr Server ->                           -- server : TInterface (Name {namespace = "Soup", name = "Server"})
    Ptr Soup.Message.Message ->             -- msg : TInterface (Name {namespace = "Soup", name = "Message"})
    IO ()

{- |
Resumes I\/O on /@msg@/. Use this to resume after calling
'GI.Soup.Objects.Server.serverPauseMessage', or after adding a new chunk to a
chunked response.

I\/O won\'t actually resume until you return to the main loop.

This must only be called on @/SoupMessages/@ which were created by the
'GI.Soup.Objects.Server.Server' and are currently doing I\/O, such as those passed into a
'GI.Soup.Callbacks.ServerCallback' or emitted in a 'GI.Soup.Objects.Server.Server'::@/request-read/@ signal.
-}
serverUnpauseMessage ::
    (B.CallStack.HasCallStack, MonadIO m, IsServer a, Soup.Message.IsMessage b) =>
    a
    {- ^ /@server@/: a 'GI.Soup.Objects.Server.Server' -}
    -> b
    {- ^ /@msg@/: a 'GI.Soup.Objects.Message.Message' associated with /@server@/. -}
    -> m ()
serverUnpauseMessage server msg = liftIO $ do
    server' <- unsafeManagedPtrCastPtr server
    msg' <- unsafeManagedPtrCastPtr msg
    soup_server_unpause_message server' msg'
    touchManagedPtr server
    touchManagedPtr msg
    return ()

data ServerUnpauseMessageMethodInfo
instance (signature ~ (b -> m ()), MonadIO m, IsServer a, Soup.Message.IsMessage b) => O.MethodInfo ServerUnpauseMessageMethodInfo a signature where
    overloadedMethod _ = serverUnpauseMessage