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

GI.Soup.Callbacks

Description

 
Synopsis

Signals

AuthDomainBasicAuthCallback

type AuthDomainBasicAuthCallback Source #

Arguments

 = AuthDomainBasic

domain: the domain

-> ServerMessage

msg: the message being authenticated

-> Text

username: the username provided by the client

-> Text

password: the password provided by the client

-> IO Bool

Returns: True if username and password are valid

Callback used by AuthDomainBasic for authentication purposes.

The application should verify that username and password and valid and return True or False.

If you are maintaining your own password database (rather than using the password to authenticate against some other system like PAM or a remote server), you should make sure you know what you are doing. In particular, don't store cleartext passwords, or easily-computed hashes of cleartext passwords, even if you don't care that much about the security of your server, because users will frequently use the same password for multiple sites, and so compromising any site with a cleartext (or easily-cracked) password database may give attackers access to other more-interesting sites as well.

type AuthDomainBasicAuthCallback_WithClosures Source #

Arguments

 = AuthDomainBasic

domain: the domain

-> ServerMessage

msg: the message being authenticated

-> Text

username: the username provided by the client

-> Text

password: the password provided by the client

-> Ptr ()

userData: the data passed to [methodauthDomainBasic.set_auth_callback]

-> IO Bool

Returns: True if username and password are valid

Callback used by AuthDomainBasic for authentication purposes.

The application should verify that username and password and valid and return True or False.

If you are maintaining your own password database (rather than using the password to authenticate against some other system like PAM or a remote server), you should make sure you know what you are doing. In particular, don't store cleartext passwords, or easily-computed hashes of cleartext passwords, even if you don't care that much about the security of your server, because users will frequently use the same password for multiple sites, and so compromising any site with a cleartext (or easily-cracked) password database may give attackers access to other more-interesting sites as well.

type C_AuthDomainBasicAuthCallback = Ptr AuthDomainBasic -> Ptr ServerMessage -> CString -> CString -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

dynamic_AuthDomainBasicAuthCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsAuthDomainBasic a, IsServerMessage b) 
=> FunPtr C_AuthDomainBasicAuthCallback 
-> a

domain: the domain

-> b

msg: the message being authenticated

-> Text

username: the username provided by the client

-> Text

password: the password provided by the client

-> Ptr ()

userData: the data passed to [methodauthDomainBasic.set_auth_callback]

-> m Bool

Returns: True if username and password are valid

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

AuthDomainDigestAuthCallback

type AuthDomainDigestAuthCallback Source #

Arguments

 = AuthDomainDigest

domain: the domain

-> ServerMessage

msg: the message being authenticated

-> Text

username: the username provided by the client

-> IO (Maybe Text)

Returns: the encoded password, or Nothing if username is not a valid user. domain will free the password when it is done with it.

Callback used by AuthDomainDigest for authentication purposes.

The application should look up username in its password database, and return the corresponding encoded password (see AuthDomainDigest.encode_password.

type AuthDomainDigestAuthCallback_WithClosures Source #

Arguments

 = AuthDomainDigest

domain: the domain

-> ServerMessage

msg: the message being authenticated

-> Text

username: the username provided by the client

-> Ptr ()

userData: the data passed to [methodauthDomainDigest.set_auth_callback]

-> IO (Maybe Text)

Returns: the encoded password, or Nothing if username is not a valid user. domain will free the password when it is done with it.

Callback used by AuthDomainDigest for authentication purposes.

The application should look up username in its password database, and return the corresponding encoded password (see AuthDomainDigest.encode_password.

type C_AuthDomainDigestAuthCallback = Ptr AuthDomainDigest -> Ptr ServerMessage -> CString -> Ptr () -> IO CString Source #

Type for the callback on the (unwrapped) C side.

dynamic_AuthDomainDigestAuthCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsAuthDomainDigest a, IsServerMessage b) 
=> FunPtr C_AuthDomainDigestAuthCallback 
-> a

domain: the domain

-> b

msg: the message being authenticated

-> Text

username: the username provided by the client

-> Ptr ()

userData: the data passed to [methodauthDomainDigest.set_auth_callback]

-> m (Maybe Text)

Returns: the encoded password, or Nothing if username is not a valid user. domain will free the password when it is done with it.

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

AuthDomainFilter

type AuthDomainFilter Source #

Arguments

 = AuthDomain

domain: a AuthDomain

-> ServerMessage

msg: a ServerMessage

-> IO Bool

Returns: True if msg requires authentication, False if not.

The prototype for a AuthDomain filter.

See [methodauthDomain.set_filter] for details.

type AuthDomainFilter_WithClosures Source #

Arguments

 = AuthDomain

domain: a AuthDomain

-> ServerMessage

msg: a ServerMessage

-> Ptr ()

userData: the data passed to [methodauthDomain.set_filter]

-> IO Bool

Returns: True if msg requires authentication, False if not.

The prototype for a AuthDomain filter.

See [methodauthDomain.set_filter] for details.

type C_AuthDomainFilter = Ptr AuthDomain -> Ptr ServerMessage -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

drop_closures_AuthDomainFilter :: AuthDomainFilter -> AuthDomainFilter_WithClosures Source #

A simple wrapper that ignores the closure arguments.

dynamic_AuthDomainFilter Source #

Arguments

:: (HasCallStack, MonadIO m, IsAuthDomain a, IsServerMessage b) 
=> FunPtr C_AuthDomainFilter 
-> a

domain: a AuthDomain

-> b

msg: a ServerMessage

-> Ptr ()

userData: the data passed to [methodauthDomain.set_filter]

-> m Bool

Returns: True if msg requires authentication, False if not.

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

genClosure_AuthDomainFilter :: MonadIO m => AuthDomainFilter -> m (GClosure C_AuthDomainFilter) Source #

Wrap the callback into a GClosure.

mk_AuthDomainFilter :: C_AuthDomainFilter -> IO (FunPtr C_AuthDomainFilter) Source #

Generate a function pointer callable from C code, from a C_AuthDomainFilter.

AuthDomainGenericAuthCallback

type AuthDomainGenericAuthCallback Source #

Arguments

 = AuthDomain

domain: a AuthDomain

-> ServerMessage

msg: the ServerMessage being authenticated

-> Text

username: the username from msg

-> IO Bool

Returns: True if msg is authenticated, False if not.

The prototype for a AuthDomain generic authentication callback.

The callback should look up the user's password, call [methodauthDomain.check_password], and use the return value from that method as its own return value.

In general, for security reasons, it is preferable to use the auth-domain-specific auth callbacks (eg, [callbackauthDomainBasicAuthCallback] and [callbackauthDomainDigestAuthCallback]), because they don't require keeping a cleartext password database. Most users will use the same password for many different sites, meaning if any site with a cleartext password database is compromised, accounts on other servers might be compromised as well. For many of the cases where [classserver] is used, this is not really relevant, but it may still be worth considering.

type AuthDomainGenericAuthCallback_WithClosures Source #

Arguments

 = AuthDomain

domain: a AuthDomain

-> ServerMessage

msg: the ServerMessage being authenticated

-> Text

username: the username from msg

-> Ptr ()

userData: the data passed to [methodauthDomain.set_generic_auth_callback]

-> IO Bool

Returns: True if msg is authenticated, False if not.

The prototype for a AuthDomain generic authentication callback.

The callback should look up the user's password, call [methodauthDomain.check_password], and use the return value from that method as its own return value.

In general, for security reasons, it is preferable to use the auth-domain-specific auth callbacks (eg, [callbackauthDomainBasicAuthCallback] and [callbackauthDomainDigestAuthCallback]), because they don't require keeping a cleartext password database. Most users will use the same password for many different sites, meaning if any site with a cleartext password database is compromised, accounts on other servers might be compromised as well. For many of the cases where [classserver] is used, this is not really relevant, but it may still be worth considering.

type C_AuthDomainGenericAuthCallback = Ptr AuthDomain -> Ptr ServerMessage -> CString -> Ptr () -> IO CInt Source #

Type for the callback on the (unwrapped) C side.

dynamic_AuthDomainGenericAuthCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsAuthDomain a, IsServerMessage b) 
=> FunPtr C_AuthDomainGenericAuthCallback 
-> a

domain: a AuthDomain

-> b

msg: the ServerMessage being authenticated

-> Text

username: the username from msg

-> Ptr ()

userData: the data passed to [methodauthDomain.set_generic_auth_callback]

-> m Bool

Returns: True if msg is authenticated, False if not.

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

LoggerFilter

type C_LoggerFilter = Ptr Logger -> Ptr Message -> Ptr () -> IO CUInt Source #

Type for the callback on the (unwrapped) C side.

type LoggerFilter Source #

Arguments

 = Logger

logger: the Logger

-> Message

msg: the message being logged

-> IO LoggerLogLevel

Returns: a [enumloggerLogLevel] value indicating how much of the message to log

The prototype for a logging filter.

The filter callback will be invoked for each request or response, and should analyze it and return a [enumloggerLogLevel] value indicating how much of the message to log.

type LoggerFilter_WithClosures Source #

Arguments

 = Logger

logger: the Logger

-> Message

msg: the message being logged

-> Ptr ()

userData: the data passed to [methodlogger.set_request_filter] or [methodlogger.set_response_filter]

-> IO LoggerLogLevel

Returns: a [enumloggerLogLevel] value indicating how much of the message to log

The prototype for a logging filter.

The filter callback will be invoked for each request or response, and should analyze it and return a [enumloggerLogLevel] value indicating how much of the message to log.

drop_closures_LoggerFilter :: LoggerFilter -> LoggerFilter_WithClosures Source #

A simple wrapper that ignores the closure arguments.

dynamic_LoggerFilter Source #

Arguments

:: (HasCallStack, MonadIO m, IsLogger a, IsMessage b) 
=> FunPtr C_LoggerFilter 
-> a

logger: the Logger

-> b

msg: the message being logged

-> Ptr ()

userData: the data passed to [methodlogger.set_request_filter] or [methodlogger.set_response_filter]

-> m LoggerLogLevel

Returns: a [enumloggerLogLevel] value indicating how much of the message to log

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

genClosure_LoggerFilter :: MonadIO m => LoggerFilter -> m (GClosure C_LoggerFilter) Source #

Wrap the callback into a GClosure.

mk_LoggerFilter :: C_LoggerFilter -> IO (FunPtr C_LoggerFilter) Source #

Generate a function pointer callable from C code, from a C_LoggerFilter.

LoggerPrinter

type C_LoggerPrinter = Ptr Logger -> CUInt -> Int8 -> CString -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type LoggerPrinter Source #

Arguments

 = Logger

logger: the Logger

-> LoggerLogLevel

level: the level of the information being printed.

-> Int8

direction: a single-character prefix to data

-> Text

data: data to print

-> IO () 

The prototype for a custom printing callback.

level indicates what kind of information is being printed. Eg, it will be LoggerLogLevelHeaders if data is header data.

direction is either '<', '>', or ' ', and data is the single line to print; the printer is expected to add a terminating newline.

To get the effect of the default printer, you would do:

c code

printf ("%c %s\n", direction, data);

type LoggerPrinter_WithClosures Source #

Arguments

 = Logger

logger: the Logger

-> LoggerLogLevel

level: the level of the information being printed.

-> Int8

direction: a single-character prefix to data

-> Text

data: data to print

-> Ptr ()

userData: the data passed to [methodlogger.set_printer]

-> IO () 

The prototype for a custom printing callback.

level indicates what kind of information is being printed. Eg, it will be LoggerLogLevelHeaders if data is header data.

direction is either '<', '>', or ' ', and data is the single line to print; the printer is expected to add a terminating newline.

To get the effect of the default printer, you would do:

c code

printf ("%c %s\n", direction, data);

drop_closures_LoggerPrinter :: LoggerPrinter -> LoggerPrinter_WithClosures Source #

A simple wrapper that ignores the closure arguments.

dynamic_LoggerPrinter Source #

Arguments

:: (HasCallStack, MonadIO m, IsLogger a) 
=> FunPtr C_LoggerPrinter 
-> a

logger: the Logger

-> LoggerLogLevel

level: the level of the information being printed.

-> Int8

direction: a single-character prefix to data

-> Text

data: data to print

-> Ptr ()

userData: the data passed to [methodlogger.set_printer]

-> m () 

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

genClosure_LoggerPrinter :: MonadIO m => LoggerPrinter -> m (GClosure C_LoggerPrinter) Source #

Wrap the callback into a GClosure.

mk_LoggerPrinter :: C_LoggerPrinter -> IO (FunPtr C_LoggerPrinter) Source #

Generate a function pointer callable from C code, from a C_LoggerPrinter.

MessageHeadersForeachFunc

type C_MessageHeadersForeachFunc = CString -> CString -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type MessageHeadersForeachFunc Source #

Arguments

 = Text

name: the header name

-> Text

value: the header value

-> IO () 

The callback passed to [methodmessageHeaders.foreach].

type MessageHeadersForeachFunc_WithClosures Source #

Arguments

 = Text

name: the header name

-> Text

value: the header value

-> Ptr ()

userData: the data passed to [methodmessageHeaders.foreach]

-> IO () 

The callback passed to [methodmessageHeaders.foreach].

dynamic_MessageHeadersForeachFunc Source #

Arguments

:: (HasCallStack, MonadIO m) 
=> FunPtr C_MessageHeadersForeachFunc 
-> Text

name: the header name

-> Text

value: the header value

-> Ptr ()

userData: the data passed to [methodmessageHeaders.foreach]

-> m () 

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

ServerCallback

type C_ServerCallback = Ptr Server -> Ptr ServerMessage -> CString -> Ptr (GHashTable CString CString) -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type ServerCallback Source #

Arguments

 = Server

server: the Server

-> ServerMessage

msg: the message being processed

-> Text

path: the path component of msg's Request-URI

-> Maybe (Map Text Text)

query: the parsed query component of msg's Request-URI

-> IO () 

A callback used to handle requests to a [classserver].

path and query contain the likewise-named components of the Request-URI, subject to certain assumptions. By default, [classserver] decodes all percent-encoding in the URI path, such that "/foo%2Fbar" is treated the same as "/foo/bar". If your server is serving resources in some non-POSIX-filesystem namespace, you may want to distinguish those as two distinct paths. In that case, you can set the [propertyserver:raw-paths] property when creating the [classserver], and it will leave those characters undecoded.

query contains the query component of the Request-URI parsed according to the rules for HTML form handling. Although this is the only commonly-used query string format in HTTP, there is nothing that actually requires that HTTP URIs use that format; if your server needs to use some other format, you can just ignore query, and call [methodmessage.get_uri] and parse the URI's query field yourself.

See [methodserver.add_handler] and [methodserver.add_early_handler] for details of what handlers can/should do.

type ServerCallback_WithClosures Source #

Arguments

 = Server

server: the Server

-> ServerMessage

msg: the message being processed

-> Text

path: the path component of msg's Request-URI

-> Maybe (Map Text Text)

query: the parsed query component of msg's Request-URI

-> Ptr ()

userData: the data passed to [methodserver.add_handler] or [methodserver.add_early_handler].

-> IO () 

A callback used to handle requests to a [classserver].

path and query contain the likewise-named components of the Request-URI, subject to certain assumptions. By default, [classserver] decodes all percent-encoding in the URI path, such that "/foo%2Fbar" is treated the same as "/foo/bar". If your server is serving resources in some non-POSIX-filesystem namespace, you may want to distinguish those as two distinct paths. In that case, you can set the [propertyserver:raw-paths] property when creating the [classserver], and it will leave those characters undecoded.

query contains the query component of the Request-URI parsed according to the rules for HTML form handling. Although this is the only commonly-used query string format in HTTP, there is nothing that actually requires that HTTP URIs use that format; if your server needs to use some other format, you can just ignore query, and call [methodmessage.get_uri] and parse the URI's query field yourself.

See [methodserver.add_handler] and [methodserver.add_early_handler] for details of what handlers can/should do.

drop_closures_ServerCallback :: ServerCallback -> ServerCallback_WithClosures Source #

A simple wrapper that ignores the closure arguments.

dynamic_ServerCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsServerMessage b) 
=> FunPtr C_ServerCallback 
-> a

server: the Server

-> b

msg: the message being processed

-> Text

path: the path component of msg's Request-URI

-> Maybe (Map Text Text)

query: the parsed query component of msg's Request-URI

-> Ptr ()

userData: the data passed to [methodserver.add_handler] or [methodserver.add_early_handler].

-> m () 

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.

genClosure_ServerCallback :: MonadIO m => ServerCallback -> m (GClosure C_ServerCallback) Source #

Wrap the callback into a GClosure.

mk_ServerCallback :: C_ServerCallback -> IO (FunPtr C_ServerCallback) Source #

Generate a function pointer callable from C code, from a C_ServerCallback.

ServerWebsocketCallback

type C_ServerWebsocketCallback = Ptr Server -> Ptr ServerMessage -> CString -> Ptr WebsocketConnection -> Ptr () -> IO () Source #

Type for the callback on the (unwrapped) C side.

type ServerWebsocketCallback Source #

Arguments

 = Server

server: the Server

-> ServerMessage

msg: the ServerMessage

-> Text

path: the path component of msg's Request-URI

-> WebsocketConnection

connection: the newly created WebSocket connection

-> IO () 

A callback used to handle WebSocket requests to a Server.

The callback will be invoked after sending the handshake response back to the client (and is only invoked if the handshake was successful).

path contains the path of the Request-URI, subject to the same rules as [callbackserverCallback] (qv).

type ServerWebsocketCallback_WithClosures Source #

Arguments

 = Server

server: the Server

-> ServerMessage

msg: the ServerMessage

-> Text

path: the path component of msg's Request-URI

-> WebsocketConnection

connection: the newly created WebSocket connection

-> Ptr ()

userData: the data passed to soupServerAddHandler

-> IO () 

A callback used to handle WebSocket requests to a Server.

The callback will be invoked after sending the handshake response back to the client (and is only invoked if the handshake was successful).

path contains the path of the Request-URI, subject to the same rules as [callbackserverCallback] (qv).

dynamic_ServerWebsocketCallback Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsServerMessage b, IsWebsocketConnection c) 
=> FunPtr C_ServerWebsocketCallback 
-> a

server: the Server

-> b

msg: the ServerMessage

-> Text

path: the path component of msg's Request-URI

-> c

connection: the newly created WebSocket connection

-> Ptr ()

userData: the data passed to soupServerAddHandler

-> m () 

Given a pointer to a foreign C function, wrap it into a function callable from Haskell.