{- |
Copyright  : Will Thompson, Iñaki García Etxebarria and Jonas Platte
License    : LGPL-2.1
Maintainer : Iñaki García Etxebarria (inaki@blueleaf.cc)

/No description available in the introspection data./
-}

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

module GI.Soup.Objects.Server
    (

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


 -- * Methods
-- ** acceptIostream #method:acceptIostream#

#if ENABLE_OVERLOADING
    ServerAcceptIostreamMethodInfo          ,
#endif
    serverAcceptIostream                    ,


-- ** addAuthDomain #method:addAuthDomain#

#if ENABLE_OVERLOADING
    ServerAddAuthDomainMethodInfo           ,
#endif
    serverAddAuthDomain                     ,


-- ** addEarlyHandler #method:addEarlyHandler#

#if ENABLE_OVERLOADING
    ServerAddEarlyHandlerMethodInfo         ,
#endif
    serverAddEarlyHandler                   ,


-- ** addHandler #method:addHandler#

#if ENABLE_OVERLOADING
    ServerAddHandlerMethodInfo              ,
#endif
    serverAddHandler                        ,


-- ** addWebsocketHandler #method:addWebsocketHandler#

#if ENABLE_OVERLOADING
    ServerAddWebsocketHandlerMethodInfo     ,
#endif
    serverAddWebsocketHandler               ,


-- ** disconnect #method:disconnect#

#if ENABLE_OVERLOADING
    ServerDisconnectMethodInfo              ,
#endif
    serverDisconnect                        ,


-- ** getAsyncContext #method:getAsyncContext#

#if ENABLE_OVERLOADING
    ServerGetAsyncContextMethodInfo         ,
#endif
    serverGetAsyncContext                   ,


-- ** getListener #method:getListener#

#if ENABLE_OVERLOADING
    ServerGetListenerMethodInfo             ,
#endif
    serverGetListener                       ,


-- ** getListeners #method:getListeners#

#if ENABLE_OVERLOADING
    ServerGetListenersMethodInfo            ,
#endif
    serverGetListeners                      ,


-- ** getPort #method:getPort#

#if ENABLE_OVERLOADING
    ServerGetPortMethodInfo                 ,
#endif
    serverGetPort                           ,


-- ** getUris #method:getUris#

#if ENABLE_OVERLOADING
    ServerGetUrisMethodInfo                 ,
#endif
    serverGetUris                           ,


-- ** isHttps #method:isHttps#

#if ENABLE_OVERLOADING
    ServerIsHttpsMethodInfo                 ,
#endif
    serverIsHttps                           ,


-- ** listen #method:listen#

#if ENABLE_OVERLOADING
    ServerListenMethodInfo                  ,
#endif
    serverListen                            ,


-- ** listenAll #method:listenAll#

#if ENABLE_OVERLOADING
    ServerListenAllMethodInfo               ,
#endif
    serverListenAll                         ,


-- ** listenFd #method:listenFd#

#if ENABLE_OVERLOADING
    ServerListenFdMethodInfo                ,
#endif
    serverListenFd                          ,


-- ** listenLocal #method:listenLocal#

#if ENABLE_OVERLOADING
    ServerListenLocalMethodInfo             ,
#endif
    serverListenLocal                       ,


-- ** listenSocket #method:listenSocket#

#if ENABLE_OVERLOADING
    ServerListenSocketMethodInfo            ,
#endif
    serverListenSocket                      ,


-- ** pauseMessage #method:pauseMessage#

#if ENABLE_OVERLOADING
    ServerPauseMessageMethodInfo            ,
#endif
    serverPauseMessage                      ,


-- ** quit #method:quit#

#if ENABLE_OVERLOADING
    ServerQuitMethodInfo                    ,
#endif
    serverQuit                              ,


-- ** removeAuthDomain #method:removeAuthDomain#

#if ENABLE_OVERLOADING
    ServerRemoveAuthDomainMethodInfo        ,
#endif
    serverRemoveAuthDomain                  ,


-- ** removeHandler #method:removeHandler#

#if ENABLE_OVERLOADING
    ServerRemoveHandlerMethodInfo           ,
#endif
    serverRemoveHandler                     ,


-- ** run #method:run#

#if ENABLE_OVERLOADING
    ServerRunMethodInfo                     ,
#endif
    serverRun                               ,


-- ** runAsync #method:runAsync#

#if ENABLE_OVERLOADING
    ServerRunAsyncMethodInfo                ,
#endif
    serverRunAsync                          ,


-- ** setSslCertFile #method:setSslCertFile#

#if ENABLE_OVERLOADING
    ServerSetSslCertFileMethodInfo          ,
#endif
    serverSetSslCertFile                    ,


-- ** unpauseMessage #method:unpauseMessage#

#if ENABLE_OVERLOADING
    ServerUnpauseMessageMethodInfo          ,
#endif
    serverUnpauseMessage                    ,




 -- * Properties
-- ** asyncContext #attr:asyncContext#
{- | The server\'s 'GI.GLib.Structs.MainContext.MainContext', if you are using the old API.
Servers created using 'GI.Soup.Objects.Server.serverListen' will listen on
the 'GI.GLib.Structs.MainContext.MainContext' that was the thread-default context at
the time 'GI.Soup.Objects.Server.serverListen' was called.
-}
#if ENABLE_OVERLOADING
    ServerAsyncContextPropertyInfo          ,
#endif
    constructServerAsyncContext             ,
    getServerAsyncContext                   ,
#if ENABLE_OVERLOADING
    serverAsyncContext                      ,
#endif


-- ** httpAliases #attr:httpAliases#
{- | A 'Nothing'-terminated array of URI schemes that should be
considered to be aliases for \"http\". Eg, if this included
\<literal>\"dav\"\<\/literal>, than a URI of
\<literal>dav:\/\/example.com\/path\<\/literal> would be treated
identically to \<literal>http:\/\/example.com\/path\<\/literal>.
In particular, this is needed in cases where a client
sends requests with absolute URIs, where those URIs do
not use \"http:\".

The default value is an array containing the single element
\<literal>\"*\"\<\/literal>, a special value which means that
any scheme except \"https\" is considered to be an alias for
\"http\".

See also 'GI.Soup.Objects.Server.Server':@/https-aliases/@.

/Since: 2.44/
-}
#if ENABLE_OVERLOADING
    ServerHttpAliasesPropertyInfo           ,
#endif
    clearServerHttpAliases                  ,
    constructServerHttpAliases              ,
    getServerHttpAliases                    ,
#if ENABLE_OVERLOADING
    serverHttpAliases                       ,
#endif
    setServerHttpAliases                    ,


-- ** httpsAliases #attr:httpsAliases#
{- | A comma-delimited list of URI schemes that should be
considered to be aliases for \"https\". See
'GI.Soup.Objects.Server.Server':@/http-aliases/@ for more information.

The default value is 'Nothing', meaning that no URI schemes
are considered aliases for \"https\".

/Since: 2.44/
-}
#if ENABLE_OVERLOADING
    ServerHttpsAliasesPropertyInfo          ,
#endif
    clearServerHttpsAliases                 ,
    constructServerHttpsAliases             ,
    getServerHttpsAliases                   ,
#if ENABLE_OVERLOADING
    serverHttpsAliases                      ,
#endif
    setServerHttpsAliases                   ,


-- ** interface #attr:interface#
{- | The address of the network interface the server is
listening on, if you are using the old 'GI.Soup.Objects.Server.Server' API.
(This will not be set if you use 'GI.Soup.Objects.Server.serverListen',
etc.)
-}
#if ENABLE_OVERLOADING
    ServerInterfacePropertyInfo             ,
#endif
    constructServerInterface                ,
    getServerInterface                      ,
#if ENABLE_OVERLOADING
    serverInterface                         ,
#endif


-- ** port #attr:port#
{- | The port the server is listening on, if you are using the
old 'GI.Soup.Objects.Server.Server' API. (This will not be set if you use
'GI.Soup.Objects.Server.serverListen', etc.)
-}
#if ENABLE_OVERLOADING
    ServerPortPropertyInfo                  ,
#endif
    constructServerPort                     ,
    getServerPort                           ,
#if ENABLE_OVERLOADING
    serverPort                              ,
#endif


-- ** rawPaths #attr:rawPaths#
{- | /No description available in the introspection data./
-}
#if ENABLE_OVERLOADING
    ServerRawPathsPropertyInfo              ,
#endif
    constructServerRawPaths                 ,
    getServerRawPaths                       ,
#if ENABLE_OVERLOADING
    serverRawPaths                          ,
#endif


-- ** serverHeader #attr:serverHeader#
{- | If non-'Nothing', the value to use for the \"Server\" header on
'GI.Soup.Objects.Message.Message'\<!-- -->s processed by this server.

The Server header is the server equivalent of the
User-Agent header, and provides information about the
server and its components. It contains a list of one or
more product tokens, separated by whitespace, with the most
significant product token coming first. The tokens must be
brief, ASCII, and mostly alphanumeric (although \"-\", \"_\",
and \".\" are also allowed), and may optionally include a \"\/\"
followed by a version string. You may also put comments,
enclosed in parentheses, between or after the tokens.

Some HTTP server implementations intentionally do not use
version numbers in their Server header, so that
installations running older versions of the server don\'t
end up advertising their vulnerability to specific security
holes.

As with 'GI.Soup.Objects.Session.Session':@/user_agent/@, if you set a
'GI.Soup.Objects.Server.Server':@/server_header/@ property that has trailing whitespace,
'GI.Soup.Objects.Server.Server' will append its own product token (eg,
\"\<literal>libsoup\/2.3.2\<\/literal>\") to the end of the
header for you.
-}
#if ENABLE_OVERLOADING
    ServerServerHeaderPropertyInfo          ,
#endif
    clearServerServerHeader                 ,
    constructServerServerHeader             ,
    getServerServerHeader                   ,
#if ENABLE_OVERLOADING
    serverServerHeader                      ,
#endif
    setServerServerHeader                   ,


-- ** sslCertFile #attr:sslCertFile#
{- | Path to a file containing a PEM-encoded certificate.

If you set this property and 'GI.Soup.Objects.Server.Server':@/ssl-key-file/@ at
construct time, then @/soup_server_new()/@ will try to read the
files; if it cannot, it will return 'Nothing', with no explicit
indication of what went wrong (and logging a warning with
newer versions of glib, since returning 'Nothing' from a
constructor is illegal).
-}
#if ENABLE_OVERLOADING
    ServerSslCertFilePropertyInfo           ,
#endif
    constructServerSslCertFile              ,
    getServerSslCertFile                    ,
#if ENABLE_OVERLOADING
    serverSslCertFile                       ,
#endif


-- ** sslKeyFile #attr:sslKeyFile#
{- | Path to a file containing a PEM-encoded private key. See
'GI.Soup.Objects.Server.Server':@/ssl-cert-file/@ for more information about how this
is used.
-}
#if ENABLE_OVERLOADING
    ServerSslKeyFilePropertyInfo            ,
#endif
    constructServerSslKeyFile               ,
    getServerSslKeyFile                     ,
#if ENABLE_OVERLOADING
    serverSslKeyFile                        ,
#endif


-- ** tlsCertificate #attr:tlsCertificate#
{- | A 'GI.Gio.Objects.TlsCertificate.TlsCertificate' that has a 'GI.Gio.Objects.TlsCertificate.TlsCertificate':@/private-key/@
set. If this is set, then the server will be able to speak
https in addition to (or instead of) plain http.

Alternatively, you can call 'GI.Soup.Objects.Server.serverSetSslCertFile'
to have 'GI.Soup.Objects.Server.Server' read in a a certificate from a file.

/Since: 2.38/
-}
#if ENABLE_OVERLOADING
    ServerTlsCertificatePropertyInfo        ,
#endif
    constructServerTlsCertificate           ,
    getServerTlsCertificate                 ,
#if ENABLE_OVERLOADING
    serverTlsCertificate                    ,
#endif




 -- * Signals
-- ** requestAborted #signal:requestAborted#

    C_ServerRequestAbortedCallback          ,
    ServerRequestAbortedCallback            ,
#if ENABLE_OVERLOADING
    ServerRequestAbortedSignalInfo          ,
#endif
    afterServerRequestAborted               ,
    genClosure_ServerRequestAborted         ,
    mk_ServerRequestAbortedCallback         ,
    noServerRequestAbortedCallback          ,
    onServerRequestAborted                  ,
    wrap_ServerRequestAbortedCallback       ,


-- ** requestFinished #signal:requestFinished#

    C_ServerRequestFinishedCallback         ,
    ServerRequestFinishedCallback           ,
#if ENABLE_OVERLOADING
    ServerRequestFinishedSignalInfo         ,
#endif
    afterServerRequestFinished              ,
    genClosure_ServerRequestFinished        ,
    mk_ServerRequestFinishedCallback        ,
    noServerRequestFinishedCallback         ,
    onServerRequestFinished                 ,
    wrap_ServerRequestFinishedCallback      ,


-- ** requestRead #signal:requestRead#

    C_ServerRequestReadCallback             ,
    ServerRequestReadCallback               ,
#if ENABLE_OVERLOADING
    ServerRequestReadSignalInfo             ,
#endif
    afterServerRequestRead                  ,
    genClosure_ServerRequestRead            ,
    mk_ServerRequestReadCallback            ,
    noServerRequestReadCallback             ,
    onServerRequestRead                     ,
    wrap_ServerRequestReadCallback          ,


-- ** requestStarted #signal:requestStarted#

    C_ServerRequestStartedCallback          ,
    ServerRequestStartedCallback            ,
#if ENABLE_OVERLOADING
    ServerRequestStartedSignalInfo          ,
#endif
    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.GClosure as B.GClosure
import qualified Data.GI.Base.GError as B.GError
import qualified Data.GI.Base.GVariant as B.GVariant
import qualified Data.GI.Base.GValue as B.GValue
import qualified Data.GI.Base.GParamSpec as B.GParamSpec
import qualified Data.GI.Base.CallStack as B.CallStack
import qualified Data.GI.Base.Properties as B.Properties
import qualified Data.Text as T
import qualified Data.ByteString.Char8 as B
import qualified Data.Map as Map
import qualified Foreign.Ptr as FP
import qualified GHC.OverloadedLabels as OL

import qualified GI.GLib.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

-- | Memory-managed wrapper type.
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


-- | Type class for types which can be safely cast to `Server`, for instance with `toServer`.
class (GObject o, O.IsDescendantOf Server o) => IsServer o
instance (GObject o, O.IsDescendantOf Server o) => IsServer o

instance O.HasParentTypes Server
type instance O.ParentTypes Server = '[GObject.Object.Object]

-- | Cast to `Server`, for types for which this is known to be safe. For general casts, use `Data.GI.Base.ManagedPtr.castTo`.
toServer :: (MonadIO m, IsServer o) => o -> m Server
toServer = liftIO . unsafeCastTo Server

-- | A convenience alias for `Nothing` :: `Maybe` `Server`.
noServer :: Maybe Server
noServer = Nothing

#if ENABLE_OVERLOADING
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 "getv" o = GObject.Object.ObjectGetvMethodInfo
    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 "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) => OL.IsLabel t (Server -> p) where
#if MIN_VERSION_base(4,10,0)
    fromLabel = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#else
    fromLabel _ = O.overloadedMethod (O.MethodProxy :: O.MethodProxy info)
#endif

#endif

-- signal Server::request-aborted
{- |
Emitted when processing has failed for a message; this
could mean either that it could not be read (if
'GI.Soup.Objects.Server.Server'::@/request_read/@ has not been emitted for it yet),
or that the response could not be written back (if
'GI.Soup.Objects.Server.Server'::@/request_read/@ has been emitted but
'GI.Soup.Objects.Server.Server'::@/request_finished/@ has not been).

/@message@/ is in an undefined state when this signal is
emitted; the signal exists primarily to allow the server to
free any state that it may have allocated in
'GI.Soup.Objects.Server.Server'::@/request_started/@.
-}
type ServerRequestAbortedCallback =
    Soup.Message.Message
    {- ^ /@message@/: the message -}
    -> Soup.ClientContext.ClientContext
    {- ^ /@client@/: the client context -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerRequestAbortedCallback`@.
noServerRequestAbortedCallback :: Maybe ServerRequestAbortedCallback
noServerRequestAbortedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_ServerRequestAbortedCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_ServerRequestAbortedCallback`.
foreign import ccall "wrapper"
    mk_ServerRequestAbortedCallback :: C_ServerRequestAbortedCallback -> IO (FunPtr C_ServerRequestAbortedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_ServerRequestAborted :: MonadIO m => ServerRequestAbortedCallback -> m (GClosure C_ServerRequestAbortedCallback)
genClosure_ServerRequestAborted cb = liftIO $ do
    let cb' = wrap_ServerRequestAbortedCallback cb
    mk_ServerRequestAbortedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `ServerRequestAbortedCallback` into a `C_ServerRequestAbortedCallback`.
wrap_ServerRequestAbortedCallback ::
    ServerRequestAbortedCallback ->
    C_ServerRequestAbortedCallback
wrap_ServerRequestAbortedCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    B.ManagedPtr.withTransient Soup.ClientContext.ClientContext client $ \client' -> do
        _cb  message' client'


{- |
Connect a signal handler for the “@request-aborted@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' server #requestAborted callback
@
-}
onServerRequestAborted :: (IsServer a, MonadIO m) => a -> ServerRequestAbortedCallback -> m SignalHandlerId
onServerRequestAborted obj cb = liftIO $ do
    let cb' = wrap_ServerRequestAbortedCallback cb
    cb'' <- mk_ServerRequestAbortedCallback cb'
    connectSignalFunPtr obj "request-aborted" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@request-aborted@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' server #requestAborted callback
@
-}
afterServerRequestAborted :: (IsServer a, MonadIO m) => a -> ServerRequestAbortedCallback -> m SignalHandlerId
afterServerRequestAborted obj cb = liftIO $ do
    let cb' = wrap_ServerRequestAbortedCallback cb
    cb'' <- mk_ServerRequestAbortedCallback cb'
    connectSignalFunPtr obj "request-aborted" cb'' SignalConnectAfter


-- signal Server::request-finished
{- |
Emitted when the server has finished writing a response to
a request.
-}
type ServerRequestFinishedCallback =
    Soup.Message.Message
    {- ^ /@message@/: the message -}
    -> Soup.ClientContext.ClientContext
    {- ^ /@client@/: the client context -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerRequestFinishedCallback`@.
noServerRequestFinishedCallback :: Maybe ServerRequestFinishedCallback
noServerRequestFinishedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_ServerRequestFinishedCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_ServerRequestFinishedCallback`.
foreign import ccall "wrapper"
    mk_ServerRequestFinishedCallback :: C_ServerRequestFinishedCallback -> IO (FunPtr C_ServerRequestFinishedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_ServerRequestFinished :: MonadIO m => ServerRequestFinishedCallback -> m (GClosure C_ServerRequestFinishedCallback)
genClosure_ServerRequestFinished cb = liftIO $ do
    let cb' = wrap_ServerRequestFinishedCallback cb
    mk_ServerRequestFinishedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `ServerRequestFinishedCallback` into a `C_ServerRequestFinishedCallback`.
wrap_ServerRequestFinishedCallback ::
    ServerRequestFinishedCallback ->
    C_ServerRequestFinishedCallback
wrap_ServerRequestFinishedCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    B.ManagedPtr.withTransient Soup.ClientContext.ClientContext client $ \client' -> do
        _cb  message' client'


{- |
Connect a signal handler for the “@request-finished@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' server #requestFinished callback
@
-}
onServerRequestFinished :: (IsServer a, MonadIO m) => a -> ServerRequestFinishedCallback -> m SignalHandlerId
onServerRequestFinished obj cb = liftIO $ do
    let cb' = wrap_ServerRequestFinishedCallback cb
    cb'' <- mk_ServerRequestFinishedCallback cb'
    connectSignalFunPtr obj "request-finished" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@request-finished@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' server #requestFinished callback
@
-}
afterServerRequestFinished :: (IsServer a, MonadIO m) => a -> ServerRequestFinishedCallback -> m SignalHandlerId
afterServerRequestFinished obj cb = liftIO $ do
    let cb' = wrap_ServerRequestFinishedCallback cb
    cb'' <- mk_ServerRequestFinishedCallback cb'
    connectSignalFunPtr obj "request-finished" cb'' SignalConnectAfter


-- signal Server::request-read
{- |
Emitted when the server has successfully read a request.
/@message@/ will have all of its request-side information
filled in, and if the message was authenticated, /@client@/
will have information about that. This signal is emitted
before any (non-early) handlers are called for the message,
and if it sets the message\'s @/status_code/@, then normal
handler processing will be skipped.
-}
type ServerRequestReadCallback =
    Soup.Message.Message
    {- ^ /@message@/: the message -}
    -> Soup.ClientContext.ClientContext
    {- ^ /@client@/: the client context -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerRequestReadCallback`@.
noServerRequestReadCallback :: Maybe ServerRequestReadCallback
noServerRequestReadCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_ServerRequestReadCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_ServerRequestReadCallback`.
foreign import ccall "wrapper"
    mk_ServerRequestReadCallback :: C_ServerRequestReadCallback -> IO (FunPtr C_ServerRequestReadCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_ServerRequestRead :: MonadIO m => ServerRequestReadCallback -> m (GClosure C_ServerRequestReadCallback)
genClosure_ServerRequestRead cb = liftIO $ do
    let cb' = wrap_ServerRequestReadCallback cb
    mk_ServerRequestReadCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `ServerRequestReadCallback` into a `C_ServerRequestReadCallback`.
wrap_ServerRequestReadCallback ::
    ServerRequestReadCallback ->
    C_ServerRequestReadCallback
wrap_ServerRequestReadCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    B.ManagedPtr.withTransient Soup.ClientContext.ClientContext client $ \client' -> do
        _cb  message' client'


{- |
Connect a signal handler for the “@request-read@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' server #requestRead callback
@
-}
onServerRequestRead :: (IsServer a, MonadIO m) => a -> ServerRequestReadCallback -> m SignalHandlerId
onServerRequestRead obj cb = liftIO $ do
    let cb' = wrap_ServerRequestReadCallback cb
    cb'' <- mk_ServerRequestReadCallback cb'
    connectSignalFunPtr obj "request-read" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@request-read@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' server #requestRead callback
@
-}
afterServerRequestRead :: (IsServer a, MonadIO m) => a -> ServerRequestReadCallback -> m SignalHandlerId
afterServerRequestRead obj cb = liftIO $ do
    let cb' = wrap_ServerRequestReadCallback cb
    cb'' <- mk_ServerRequestReadCallback cb'
    connectSignalFunPtr obj "request-read" cb'' SignalConnectAfter


-- signal Server::request-started
{- |
Emitted when the server has started reading a new request.
/@message@/ will be completely blank; not even the
Request-Line will have been read yet. About the only thing
you can usefully do with it is connect to its signals.

If the request is read successfully, this will eventually
be followed by a 'GI.Soup.Objects.Server.Server'::@/request_read/@ signal. If a
response is then sent, the request processing will end with
a 'GI.Soup.Objects.Server.Server'::@/request_finished/@ signal. If a network error
occurs, the processing will instead end with
'GI.Soup.Objects.Server.Server'::@/request_aborted/@.
-}
type ServerRequestStartedCallback =
    Soup.Message.Message
    {- ^ /@message@/: the new message -}
    -> Soup.ClientContext.ClientContext
    {- ^ /@client@/: the client context -}
    -> IO ()

-- | A convenience synonym for @`Nothing` :: `Maybe` `ServerRequestStartedCallback`@.
noServerRequestStartedCallback :: Maybe ServerRequestStartedCallback
noServerRequestStartedCallback = Nothing

-- | Type for the callback on the (unwrapped) C side.
type C_ServerRequestStartedCallback =
    Ptr () ->                               -- object
    Ptr Soup.Message.Message ->
    Ptr Soup.ClientContext.ClientContext ->
    Ptr () ->                               -- user_data
    IO ()

-- | Generate a function pointer callable from C code, from a `C_ServerRequestStartedCallback`.
foreign import ccall "wrapper"
    mk_ServerRequestStartedCallback :: C_ServerRequestStartedCallback -> IO (FunPtr C_ServerRequestStartedCallback)

-- | Wrap the callback into a `GClosure`.
genClosure_ServerRequestStarted :: MonadIO m => ServerRequestStartedCallback -> m (GClosure C_ServerRequestStartedCallback)
genClosure_ServerRequestStarted cb = liftIO $ do
    let cb' = wrap_ServerRequestStartedCallback cb
    mk_ServerRequestStartedCallback cb' >>= B.GClosure.newGClosure


-- | Wrap a `ServerRequestStartedCallback` into a `C_ServerRequestStartedCallback`.
wrap_ServerRequestStartedCallback ::
    ServerRequestStartedCallback ->
    C_ServerRequestStartedCallback
wrap_ServerRequestStartedCallback _cb _ message client _ = do
    message' <- (newObject Soup.Message.Message) message
    B.ManagedPtr.withTransient Soup.ClientContext.ClientContext client $ \client' -> do
        _cb  message' client'


{- |
Connect a signal handler for the “@request-started@” signal, to be run before the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.on' server #requestStarted callback
@
-}
onServerRequestStarted :: (IsServer a, MonadIO m) => a -> ServerRequestStartedCallback -> m SignalHandlerId
onServerRequestStarted obj cb = liftIO $ do
    let cb' = wrap_ServerRequestStartedCallback cb
    cb'' <- mk_ServerRequestStartedCallback cb'
    connectSignalFunPtr obj "request-started" cb'' SignalConnectBefore

{- |
Connect a signal handler for the “@request-started@” signal, to be run after the default handler.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Signals.after' server #requestStarted callback
@
-}
afterServerRequestStarted :: (IsServer a, MonadIO m) => a -> ServerRequestStartedCallback -> m SignalHandlerId
afterServerRequestStarted obj cb = liftIO $ do
    let cb' = wrap_ServerRequestStartedCallback cb
    cb'' <- mk_ServerRequestStartedCallback cb'
    connectSignalFunPtr obj "request-started" cb'' SignalConnectAfter


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

{- |
Get the value of the “@async-context@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #asyncContext
@
-}
getServerAsyncContext :: (MonadIO m, IsServer o) => o -> m (Ptr ())
getServerAsyncContext obj = liftIO $ B.Properties.getObjectPropertyPtr obj "async-context"

{- |
Construct a `GValueConstruct` with valid value for the “@async-context@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerAsyncContext :: (IsServer o) => Ptr () -> IO (GValueConstruct o)
constructServerAsyncContext val = B.Properties.constructObjectPropertyPtr "async-context" val

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@http-aliases@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #httpAliases
@
-}
getServerHttpAliases :: (MonadIO m, IsServer o) => o -> m (Maybe [T.Text])
getServerHttpAliases obj = liftIO $ B.Properties.getObjectPropertyStringArray obj "http-aliases"

{- |
Set the value of the “@http-aliases@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' server [ #httpAliases 'Data.GI.Base.Attributes.:=' value ]
@
-}
setServerHttpAliases :: (MonadIO m, IsServer o) => o -> [T.Text] -> m ()
setServerHttpAliases obj val = liftIO $ B.Properties.setObjectPropertyStringArray obj "http-aliases" (Just val)

{- |
Construct a `GValueConstruct` with valid value for the “@http-aliases@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerHttpAliases :: (IsServer o) => [T.Text] -> IO (GValueConstruct o)
constructServerHttpAliases val = B.Properties.constructObjectPropertyStringArray "http-aliases" (Just val)

{- |
Set the value of the “@http-aliases@” property to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #httpAliases
@
-}
clearServerHttpAliases :: (MonadIO m, IsServer o) => o -> m ()
clearServerHttpAliases obj = liftIO $ B.Properties.setObjectPropertyStringArray obj "http-aliases" (Nothing :: Maybe [T.Text])

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@https-aliases@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #httpsAliases
@
-}
getServerHttpsAliases :: (MonadIO m, IsServer o) => o -> m (Maybe [T.Text])
getServerHttpsAliases obj = liftIO $ B.Properties.getObjectPropertyStringArray obj "https-aliases"

{- |
Set the value of the “@https-aliases@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' server [ #httpsAliases 'Data.GI.Base.Attributes.:=' value ]
@
-}
setServerHttpsAliases :: (MonadIO m, IsServer o) => o -> [T.Text] -> m ()
setServerHttpsAliases obj val = liftIO $ B.Properties.setObjectPropertyStringArray obj "https-aliases" (Just val)

{- |
Construct a `GValueConstruct` with valid value for the “@https-aliases@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerHttpsAliases :: (IsServer o) => [T.Text] -> IO (GValueConstruct o)
constructServerHttpsAliases val = B.Properties.constructObjectPropertyStringArray "https-aliases" (Just val)

{- |
Set the value of the “@https-aliases@” property to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #httpsAliases
@
-}
clearServerHttpsAliases :: (MonadIO m, IsServer o) => o -> m ()
clearServerHttpsAliases obj = liftIO $ B.Properties.setObjectPropertyStringArray obj "https-aliases" (Nothing :: Maybe [T.Text])

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@interface@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #interface
@
-}
getServerInterface :: (MonadIO m, IsServer o) => o -> m (Maybe Soup.Address.Address)
getServerInterface obj = liftIO $ B.Properties.getObjectPropertyObject obj "interface" Soup.Address.Address

{- |
Construct a `GValueConstruct` with valid value for the “@interface@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerInterface :: (IsServer o, Soup.Address.IsAddress a) => a -> IO (GValueConstruct o)
constructServerInterface val = B.Properties.constructObjectPropertyObject "interface" (Just val)

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@port@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #port
@
-}
getServerPort :: (MonadIO m, IsServer o) => o -> m Word32
getServerPort obj = liftIO $ B.Properties.getObjectPropertyUInt32 obj "port"

{- |
Construct a `GValueConstruct` with valid value for the “@port@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerPort :: (IsServer o) => Word32 -> IO (GValueConstruct o)
constructServerPort val = B.Properties.constructObjectPropertyUInt32 "port" val

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@raw-paths@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #rawPaths
@
-}
getServerRawPaths :: (MonadIO m, IsServer o) => o -> m Bool
getServerRawPaths obj = liftIO $ B.Properties.getObjectPropertyBool obj "raw-paths"

{- |
Construct a `GValueConstruct` with valid value for the “@raw-paths@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerRawPaths :: (IsServer o) => Bool -> IO (GValueConstruct o)
constructServerRawPaths val = B.Properties.constructObjectPropertyBool "raw-paths" val

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@server-header@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #serverHeader
@
-}
getServerServerHeader :: (MonadIO m, IsServer o) => o -> m (Maybe T.Text)
getServerServerHeader obj = liftIO $ B.Properties.getObjectPropertyString obj "server-header"

{- |
Set the value of the “@server-header@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.set' server [ #serverHeader 'Data.GI.Base.Attributes.:=' value ]
@
-}
setServerServerHeader :: (MonadIO m, IsServer o) => o -> T.Text -> m ()
setServerServerHeader obj val = liftIO $ B.Properties.setObjectPropertyString obj "server-header" (Just val)

{- |
Construct a `GValueConstruct` with valid value for the “@server-header@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerServerHeader :: (IsServer o) => T.Text -> IO (GValueConstruct o)
constructServerServerHeader val = B.Properties.constructObjectPropertyString "server-header" (Just val)

{- |
Set the value of the “@server-header@” property to `Nothing`.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.clear' #serverHeader
@
-}
clearServerServerHeader :: (MonadIO m, IsServer o) => o -> m ()
clearServerServerHeader obj = liftIO $ B.Properties.setObjectPropertyString obj "server-header" (Nothing :: Maybe T.Text)

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@ssl-cert-file@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #sslCertFile
@
-}
getServerSslCertFile :: (MonadIO m, IsServer o) => o -> m (Maybe T.Text)
getServerSslCertFile obj = liftIO $ B.Properties.getObjectPropertyString obj "ssl-cert-file"

{- |
Construct a `GValueConstruct` with valid value for the “@ssl-cert-file@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerSslCertFile :: (IsServer o) => T.Text -> IO (GValueConstruct o)
constructServerSslCertFile val = B.Properties.constructObjectPropertyString "ssl-cert-file" (Just val)

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@ssl-key-file@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #sslKeyFile
@
-}
getServerSslKeyFile :: (MonadIO m, IsServer o) => o -> m (Maybe T.Text)
getServerSslKeyFile obj = liftIO $ B.Properties.getObjectPropertyString obj "ssl-key-file"

{- |
Construct a `GValueConstruct` with valid value for the “@ssl-key-file@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerSslKeyFile :: (IsServer o) => T.Text -> IO (GValueConstruct o)
constructServerSslKeyFile val = B.Properties.constructObjectPropertyString "ssl-key-file" (Just val)

#if ENABLE_OVERLOADING
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
#endif

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

{- |
Get the value of the “@tls-certificate@” property.
When <https://github.com/haskell-gi/haskell-gi/wiki/Overloading overloading> is enabled, this is equivalent to

@
'Data.GI.Base.Attributes.get' server #tlsCertificate
@
-}
getServerTlsCertificate :: (MonadIO m, IsServer o) => o -> m (Maybe Gio.TlsCertificate.TlsCertificate)
getServerTlsCertificate obj = liftIO $ B.Properties.getObjectPropertyObject obj "tls-certificate" Gio.TlsCertificate.TlsCertificate

{- |
Construct a `GValueConstruct` with valid value for the “@tls-certificate@” property. This is rarely needed directly, but it is used by `Data.GI.Base.Constructible.new`.
-}
constructServerTlsCertificate :: (IsServer o, Gio.TlsCertificate.IsTlsCertificate a) => a -> IO (GValueConstruct o)
constructServerTlsCertificate val = B.Properties.constructObjectPropertyObject "tls-certificate" (Just val)

#if ENABLE_OVERLOADING
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
#endif

#if ENABLE_OVERLOADING
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, *)])
#endif

#if ENABLE_OVERLOADING
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

#endif

#if ENABLE_OVERLOADING
data ServerRequestAbortedSignalInfo
instance SignalInfo ServerRequestAbortedSignalInfo where
    type HaskellCallbackType ServerRequestAbortedSignalInfo = ServerRequestAbortedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ServerRequestAbortedCallback cb
        cb'' <- mk_ServerRequestAbortedCallback cb'
        connectSignalFunPtr obj "request-aborted" cb'' connectMode

data ServerRequestFinishedSignalInfo
instance SignalInfo ServerRequestFinishedSignalInfo where
    type HaskellCallbackType ServerRequestFinishedSignalInfo = ServerRequestFinishedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ServerRequestFinishedCallback cb
        cb'' <- mk_ServerRequestFinishedCallback cb'
        connectSignalFunPtr obj "request-finished" cb'' connectMode

data ServerRequestReadSignalInfo
instance SignalInfo ServerRequestReadSignalInfo where
    type HaskellCallbackType ServerRequestReadSignalInfo = ServerRequestReadCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ServerRequestReadCallback cb
        cb'' <- mk_ServerRequestReadCallback cb'
        connectSignalFunPtr obj "request-read" cb'' connectMode

data ServerRequestStartedSignalInfo
instance SignalInfo ServerRequestStartedSignalInfo where
    type HaskellCallbackType ServerRequestStartedSignalInfo = ServerRequestStartedCallback
    connectSignal _ obj cb connectMode = do
        let cb' = wrap_ServerRequestStartedCallback cb
        cb'' <- mk_ServerRequestStartedCallback cb'
        connectSignalFunPtr obj "request-started" cb'' connectMode

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

#endif

-- 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 ()
     )

#if ENABLE_OVERLOADING
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

#endif

-- 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 ()

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

#endif

-- 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 ()

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

#endif

-- 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 ()

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

#endif

-- 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 ()

#if ENABLE_OVERLOADING
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

#endif

-- 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 ()

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

#endif

-- 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

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

#endif

-- 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'

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

#endif

-- 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''

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

#endif

-- 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

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

#endif

-- 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''

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

#endif

-- 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'

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

#endif

-- 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 ()
     )

#if ENABLE_OVERLOADING
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

#endif

-- 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 ()
     )

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

#endif

-- 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 ()
     )

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

#endif

-- 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 ()
     )

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

#endif

-- 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 ()
     )

#if ENABLE_OVERLOADING
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

#endif

-- 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 ()

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

#endif

-- 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 ()

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

#endif

-- 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 ()

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

#endif

-- 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 ()

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

#endif

-- 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 ()

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

#endif

-- 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 ()

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

#endif

-- 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'
     )

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

#endif

-- 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 ()

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

#endif