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

GI.Soup.Objects.Server

Description

Server implements a simple HTTP server.

(The following documentation describes the current Server API, available in <application>libsoup</application> 2.48 and later. See the section "<link linkend="soup-server-old-api">The Old SoupServer Listening API</link>" in the server how-to documentation for details on the older Server API.)

To begin, create a server using soup_server_new(). Add at least one handler by calling serverAddHandler or serverAddEarlyHandler; the handler will be called to process any requests underneath the path you pass. (If you want all requests to go to the same handler, just pass "/" (or Nothing) for the path.)

When a new connection is accepted (or a new request is started on an existing persistent connection), the Server will emit requestStarted and then begin processing the request as described below, but note that once the message is assigned a Message:status-code, then callbacks after that point will be skipped. Note also that it is not defined when the callbacks happen relative to various Message signals.

Once the headers have been read, Server will check if there is a AuthDomain (qv) covering the Request-URI; if so, and if the message does not contain suitable authorization, then the AuthDomain will set a status of StatusUnauthorized on the message.

After checking for authorization, Server will look for "early" handlers (added with serverAddEarlyHandler) matching the Request-URI. If one is found, it will be run; in particular, this can be used to connect to signals to do a streaming read of the request body.

(At this point, if the request headers contain "<literal>Expect: 100-continue</literal>", and a status code has been set, then Server will skip the remaining steps and return the response. If the request headers contain "<literal>Expect: 100-continue</literal>" and no status code has been set, Server will return a StatusContinue status before continuing.)

The server will then read in the response body (if present). At this point, if there are no handlers at all defined for the Request-URI, then the server will return StatusNotFound to the client.

Otherwise (assuming no previous step assigned a status to the message) any "normal" handlers (added with serverAddHandler) for the message's Request-URI will be run.

Then, if the path has a WebSocket handler registered (and has not yet been assigned a status), Server will attempt to validate the WebSocket handshake, filling in the response and setting a status of StatusSwitchingProtocols or StatusBadRequest accordingly.

If the message still has no status code at this point (and has not been paused with serverPauseMessage), then it will be given a status of StatusInternalServerError (because at least one handler ran, but returned without assigning a status).

Finally, the server will emit requestFinished (or requestAborted if an I/O error occurred before handling was completed).

If you want to handle the special "*" URI (eg, "OPTIONS *"), you must explicitly register a handler for "*"; the default handler will not be used for that case.

If you want to process https connections in addition to (or instead of) http connections, you can either set the SERVER_TLS_CERTIFICATE property when creating the server, or else call soup_server_set_ssl_certificate() after creating it.

Once the server is set up, make one or more calls to serverListen, serverListenLocal, or serverListenAll to tell it where to listen for connections. (All ports on a Server use the same handlers; if you need to handle some ports differently, such as returning different data for http and https, you'll need to create multiple SoupServers, or else check the passed-in URI in the handler function.).

Server will begin processing connections as soon as you return to (or start) the main loop for the current thread-default MainContext.

Synopsis

Exported types

newtype Server Source #

Memory-managed wrapper type.

Constructors

Server (ManagedPtr Server) 

Instances

Instances details
Eq Server Source # 
Instance details

Defined in GI.Soup.Objects.Server

Methods

(==) :: Server -> Server -> Bool #

(/=) :: Server -> Server -> Bool #

GObject Server Source # 
Instance details

Defined in GI.Soup.Objects.Server

ManagedPtrNewtype Server Source # 
Instance details

Defined in GI.Soup.Objects.Server

Methods

toManagedPtr :: Server -> ManagedPtr Server

TypedObject Server Source # 
Instance details

Defined in GI.Soup.Objects.Server

Methods

glibType :: IO GType

HasParentTypes Server Source # 
Instance details

Defined in GI.Soup.Objects.Server

IsGValue (Maybe Server) Source #

Convert Server to and from GValue. See toGValue and fromGValue.

Instance details

Defined in GI.Soup.Objects.Server

Methods

gvalueGType_ :: IO GType

gvalueSet_ :: Ptr GValue -> Maybe Server -> IO ()

gvalueGet_ :: Ptr GValue -> IO (Maybe Server)

type ParentTypes Server Source # 
Instance details

Defined in GI.Soup.Objects.Server

type ParentTypes Server = '[Object]

class (GObject o, IsDescendantOf Server o) => IsServer o Source #

Type class for types which can be safely cast to Server, for instance with toServer.

Instances

Instances details
(GObject o, IsDescendantOf Server o) => IsServer o Source # 
Instance details

Defined in GI.Soup.Objects.Server

toServer :: (MonadIO m, IsServer o) => o -> m Server Source #

Cast to Server, for types for which this is known to be safe. For general casts, use castTo.

Methods

acceptIostream

serverAcceptIostream Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsIOStream b, IsSocketAddress c, IsSocketAddress d) 
=> a

server: a Server

-> b

stream: a IOStream

-> Maybe c

localAddr: the local SocketAddress associated with the stream

-> Maybe d

remoteAddr: the remote SocketAddress associated with the stream

-> m ()

(Can throw GError)

Add a new client stream to the server.

Since: 2.50

addAuthDomain

serverAddAuthDomain Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsAuthDomain b) 
=> a

server: a Server

-> b

authDomain: a AuthDomain

-> m () 

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.

addEarlyHandler

serverAddEarlyHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Maybe Text

path: the toplevel path for the handler

-> ServerCallback

callback: callback to invoke for requests under path

-> m () 

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 AuthDomain or a signal handler), callback will be invoked after receiving the request headers, but before receiving the request body; the message's Message:method and 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 messageBodySetAccumulate on the message's Message:request-body to turn off request-body accumulation, and connect to the message's gotChunk 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 gotBody, or else you can register a non-early handler for path as well. As long as you have not set the Message:status-code by the time gotBody is emitted, the non-early handler will be run as well.

Since: 2.50

addHandler

serverAddHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Maybe Text

path: the toplevel path for the handler

-> ServerCallback

callback: callback to invoke for requests under path

-> m () 

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 AuthDomain, an early SoupServerHandler, or a signal handler), callback will be invoked after receiving the request body; the message's Message:method, Message:request-headers, and Message:request-body fields will be filled in.

After determining what to do with the request, the callback must at a minimum call messageSetStatus (or 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 serverPauseMessage to tell server to not send the response right away. When the response is ready, call serverUnpauseMessage to cause it to be sent.

To send the response body a bit at a time using "chunked" encoding, first call messageHeadersSetEncoding to set EncodingChunked on the Message:response-headers. Then call soup_message_body_append() (or messageBodyAppendBuffer) to append each chunk as it becomes ready, and 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 messageBodyComplete to indicate that no more chunks are coming.

addWebsocketExtension

serverAddWebsocketExtension Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> GType

extensionType: a GType

-> m () 

Add support for a WebSocket extension of the given extensionType. When a WebSocket client requests an extension of extensionType, a new WebsocketExtension of type extensionType will be created to handle the request.

You can also add support for a WebSocket extension to the server at construct time by using the SOUP_SERVER_ADD_WEBSOCKET_EXTENSION property. Note that WebsocketExtensionDeflate is supported by default, use serverRemoveWebsocketExtension if you want to disable it.

Since: 2.68

addWebsocketHandler

serverAddWebsocketHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Maybe Text

path: the toplevel path for the handler

-> Maybe Text

origin: the origin of the connection

-> Maybe [Text]

protocols: the protocols supported by this handler

-> ServerWebsocketCallback

callback: callback to invoke for successful WebSocket requests under path

-> m () 

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.

disconnect

serverDisconnect Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m () 

Closes and frees server's listening sockets. If you are using the old Server APIs, this also includes the effect of serverQuit.

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

You can call serverListen, etc, after calling this function if you want to start listening again.

getAsyncContext

serverGetAsyncContext Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m (Maybe MainContext)

Returns: server's MainContext, which may be Nothing

Deprecated: If you are using serverListen, etc, thenthe server listens on the thread-default MainContext, and thisproperty 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 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.

getListener

serverGetListener Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m Socket

Returns: the listening socket.

Deprecated: If you are using serverListen, etc, then useserverGetListeners 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.

getListeners

serverGetListeners Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m [Socket]

Returns: a list of listening sockets.

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 serverGetListener, this function returns GSockets, not SoupSockets.)

getPort

serverGetPort Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m Word32

Returns: the port server is listening on.

Deprecated: If you are using serverListen, etc, then useserverGetUris to get a list of all listening addresses.

Gets the TCP port that server is listening on, if you are using the old API.

getUris

serverGetUris Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m [URI]

Returns: a list of SoupURIs, which you must free when you are done with it.

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

isHttps

serverIsHttps Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m Bool

Returns: True if server is configured to serve https.

Checks whether server is capable of https.

In order for a server to run https, you must call serverSetSslCertFile, or set the 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 Server serves https exclusively. If you are using 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 serverGetUris to see if it currently has any https listeners.

listen

serverListen Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsSocketAddress b) 
=> a

server: a Server

-> b

address: the address of the interface to listen on

-> [ServerListenOptions]

options: listening options for this server

-> m ()

(Can throw GError)

This attempts to set up server to listen for connections on address.

If options includes 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 MainContext is run.

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

listenAll

serverListenAll Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Word32

port: the port to listen on, or 0

-> [ServerListenOptions]

options: listening options for this server

-> m ()

(Can throw GError)

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 ServerListenOptionsIpv4Only, 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 serverGetUris to find out what port it ended up choosing.)

See serverListen for more details.

Since: 2.48

listenFd

serverListenFd Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Int32

fd: the file descriptor of a listening socket

-> [ServerListenOptions]

options: listening options for this server

-> m ()

(Can throw GError)

This attempts to set up server to listen for connections on fd.

See serverListen for more details.

Note that server will close fd when you free it or call serverDisconnect.

Since: 2.48

listenLocal

serverListenLocal Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Word32

port: the port to listen on, or 0

-> [ServerListenOptions]

options: listening options for this server

-> m ()

(Can throw GError)

This attempts to set up server to listen for connections on "localhost" (that is, <literal>127.0.0.1</literal> and/or <literal>[1](#g:signal:1)</literal>, depending on whether options includes ServerListenOptionsIpv4Only, 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 serverGetUris to find out what port it ended up choosing.)

See serverListen for more details.

Since: 2.48

listenSocket

serverListenSocket Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsSocket b) 
=> a

server: a Server

-> b

socket: a listening Socket

-> [ServerListenOptions]

options: listening options for this server

-> m ()

(Can throw GError)

This attempts to set up server to listen for connections on socket.

See serverListen for more details.

Since: 2.48

pauseMessage

serverPauseMessage Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsMessage b) 
=> a

server: a Server

-> b

msg: a Message associated with server.

-> m () 

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 serverUnpauseMessage to resume I/O.

This must only be called on SoupMessages which were created by the Server and are currently doing I/O, such as those passed into a ServerCallback or emitted in a requestRead signal.

quit

serverQuit Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m () 

Deprecated: When using serverListen, etc, the server willalways listen for connections, and will process them whenever thethread-default MainContext is running.

Stops processing for server, if you are using the old API. Call this to clean up after serverRunAsync, or to terminate a call to 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.

removeAuthDomain

serverRemoveAuthDomain Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsAuthDomain b) 
=> a

server: a Server

-> b

authDomain: a AuthDomain

-> m () 

Removes authDomain from server.

removeHandler

serverRemoveHandler Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Text

path: the toplevel path for the handler

-> m () 

Removes all handlers (early and normal) registered at path.

removeWebsocketExtension

serverRemoveWebsocketExtension Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> GType

extensionType: a GType

-> m () 

Removes support for WebSocket extension of type extensionType (or any subclass of extensionType) from server. You can also remove extensions enabled by default from the server at construct time by using the SOUP_SERVER_REMOVE_WEBSOCKET_EXTENSION property.

Since: 2.68

run

serverRun Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m () 

Deprecated: When using serverListen, etc, the server willalways listen for connections, and will process them whenever thethread-default MainContext is running.

Starts server, if you are using the old API, causing it to listen for and process incoming connections. Unlike serverRunAsync, this creates a MainLoop and runs it, and it will not return until someone calls serverQuit to stop the server.

runAsync

serverRunAsync Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> m () 

Deprecated: When using serverListen, etc, the server willalways listen for connections, and will process them whenever thethread-default 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 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 SERVER_ASYNC_CONTEXT property, this means the server will run whenever the glib main loop is running.

setSslCertFile

serverSetSslCertFile Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a) 
=> a

server: a Server

-> Text

sslCertFile: path to a file containing a PEM-encoded SSL/TLS certificate.

-> Text

sslKeyFile: path to a file containing a PEM-encoded private key.

-> m ()

(Can throw GError)

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 Server:tls-certificate property at construction time, if you already have a TlsCertificate.

Since: 2.48

unpauseMessage

serverUnpauseMessage Source #

Arguments

:: (HasCallStack, MonadIO m, IsServer a, IsMessage b) 
=> a

server: a Server

-> b

msg: a Message associated with server.

-> m () 

Resumes I/O on msg. Use this to resume after calling 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 Server and are currently doing I/O, such as those passed into a ServerCallback or emitted in a requestRead signal.

Properties

asyncContext

The server's MainContext, if you are using the old API. Servers created using serverListen will listen on the MainContext that was the thread-default context at the time serverListen was called.

constructServerAsyncContext :: (IsServer o, MonadIO m) => Ptr () -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “async-context” property. This is rarely needed directly, but it is used by new.

getServerAsyncContext :: (MonadIO m, IsServer o) => o -> m (Ptr ()) Source #

Get the value of the “async-context” property. When overloading is enabled, this is equivalent to

get server #asyncContext

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 Server:https-aliases.

Since: 2.44

clearServerHttpAliases :: (MonadIO m, IsServer o) => o -> m () Source #

Set the value of the “http-aliases” property to Nothing. When overloading is enabled, this is equivalent to

clear #httpAliases

constructServerHttpAliases :: (IsServer o, MonadIO m) => [Text] -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “http-aliases” property. This is rarely needed directly, but it is used by new.

getServerHttpAliases :: (MonadIO m, IsServer o) => o -> m (Maybe [Text]) Source #

Get the value of the “http-aliases” property. When overloading is enabled, this is equivalent to

get server #httpAliases

setServerHttpAliases :: (MonadIO m, IsServer o) => o -> [Text] -> m () Source #

Set the value of the “http-aliases” property. When overloading is enabled, this is equivalent to

set server [ #httpAliases := value ]

httpsAliases

A comma-delimited list of URI schemes that should be considered to be aliases for "https". See Server:http-aliases for more information.

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

Since: 2.44

clearServerHttpsAliases :: (MonadIO m, IsServer o) => o -> m () Source #

Set the value of the “https-aliases” property to Nothing. When overloading is enabled, this is equivalent to

clear #httpsAliases

constructServerHttpsAliases :: (IsServer o, MonadIO m) => [Text] -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “https-aliases” property. This is rarely needed directly, but it is used by new.

getServerHttpsAliases :: (MonadIO m, IsServer o) => o -> m (Maybe [Text]) Source #

Get the value of the “https-aliases” property. When overloading is enabled, this is equivalent to

get server #httpsAliases

setServerHttpsAliases :: (MonadIO m, IsServer o) => o -> [Text] -> m () Source #

Set the value of the “https-aliases” property. When overloading is enabled, this is equivalent to

set server [ #httpsAliases := value ]

interface

The address of the network interface the server is listening on, if you are using the old Server API. (This will not be set if you use serverListen, etc.)

constructServerInterface :: (IsServer o, MonadIO m, IsAddress a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “interface” property. This is rarely needed directly, but it is used by new.

getServerInterface :: (MonadIO m, IsServer o) => o -> m (Maybe Address) Source #

Get the value of the “interface” property. When overloading is enabled, this is equivalent to

get server #interface

port

The port the server is listening on, if you are using the old Server API. (This will not be set if you use serverListen, etc.)

constructServerPort :: (IsServer o, MonadIO m) => Word32 -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “port” property. This is rarely needed directly, but it is used by new.

getServerPort :: (MonadIO m, IsServer o) => o -> m Word32 Source #

Get the value of the “port” property. When overloading is enabled, this is equivalent to

get server #port

rawPaths

No description available in the introspection data.

constructServerRawPaths :: (IsServer o, MonadIO m) => Bool -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “raw-paths” property. This is rarely needed directly, but it is used by new.

getServerRawPaths :: (MonadIO m, IsServer o) => o -> m Bool Source #

Get the value of the “raw-paths” property. When overloading is enabled, this is equivalent to

get server #rawPaths

serverHeader

If non-Nothing, the value to use for the "Server" header on Messages 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 Session:user_agent, if you set a Server:server_header property that has trailing whitespace, Server will append its own product token (eg, "<literal>libsoup/2.3.2</literal>") to the end of the header for you.

clearServerServerHeader :: (MonadIO m, IsServer o) => o -> m () Source #

Set the value of the “server-header” property to Nothing. When overloading is enabled, this is equivalent to

clear #serverHeader

constructServerServerHeader :: (IsServer o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “server-header” property. This is rarely needed directly, but it is used by new.

getServerServerHeader :: (MonadIO m, IsServer o) => o -> m (Maybe Text) Source #

Get the value of the “server-header” property. When overloading is enabled, this is equivalent to

get server #serverHeader

setServerServerHeader :: (MonadIO m, IsServer o) => o -> Text -> m () Source #

Set the value of the “server-header” property. When overloading is enabled, this is equivalent to

set server [ #serverHeader := value ]

sslCertFile

Path to a file containing a PEM-encoded certificate.

If you set this property and 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).

constructServerSslCertFile :: (IsServer o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “ssl-cert-file” property. This is rarely needed directly, but it is used by new.

getServerSslCertFile :: (MonadIO m, IsServer o) => o -> m (Maybe Text) Source #

Get the value of the “ssl-cert-file” property. When overloading is enabled, this is equivalent to

get server #sslCertFile

sslKeyFile

Path to a file containing a PEM-encoded private key. See Server:ssl-cert-file for more information about how this is used.

constructServerSslKeyFile :: (IsServer o, MonadIO m) => Text -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “ssl-key-file” property. This is rarely needed directly, but it is used by new.

getServerSslKeyFile :: (MonadIO m, IsServer o) => o -> m (Maybe Text) Source #

Get the value of the “ssl-key-file” property. When overloading is enabled, this is equivalent to

get server #sslKeyFile

tlsCertificate

A TlsCertificate that has a 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 serverSetSslCertFile to have Server read in a a certificate from a file.

Since: 2.38

constructServerTlsCertificate :: (IsServer o, MonadIO m, IsTlsCertificate a) => a -> m (GValueConstruct o) Source #

Construct a GValueConstruct with valid value for the “tls-certificate” property. This is rarely needed directly, but it is used by new.

getServerTlsCertificate :: (MonadIO m, IsServer o) => o -> m (Maybe TlsCertificate) Source #

Get the value of the “tls-certificate” property. When overloading is enabled, this is equivalent to

get server #tlsCertificate

Signals

requestAborted

type C_ServerRequestAbortedCallback = Ptr () -> Ptr Message -> Ptr ClientContext -> Ptr () -> IO () Source #

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

type ServerRequestAbortedCallback Source #

Arguments

 = Message

message: the message

-> ClientContext

client: the client context

-> IO () 

Emitted when processing has failed for a message; this could mean either that it could not be read (if Server::request_read has not been emitted for it yet), or that the response could not be written back (if Server::request_read has been emitted but 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 Server::request_started.

afterServerRequestAborted :: (IsServer a, MonadIO m) => a -> ServerRequestAbortedCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestAborted signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after server #requestAborted callback

onServerRequestAborted :: (IsServer a, MonadIO m) => a -> ServerRequestAbortedCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestAborted signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on server #requestAborted callback

requestFinished

type C_ServerRequestFinishedCallback = Ptr () -> Ptr Message -> Ptr ClientContext -> Ptr () -> IO () Source #

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

type ServerRequestFinishedCallback Source #

Arguments

 = Message

message: the message

-> ClientContext

client: the client context

-> IO () 

Emitted when the server has finished writing a response to a request.

afterServerRequestFinished :: (IsServer a, MonadIO m) => a -> ServerRequestFinishedCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestFinished signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after server #requestFinished callback

onServerRequestFinished :: (IsServer a, MonadIO m) => a -> ServerRequestFinishedCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestFinished signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on server #requestFinished callback

requestRead

type C_ServerRequestReadCallback = Ptr () -> Ptr Message -> Ptr ClientContext -> Ptr () -> IO () Source #

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

type ServerRequestReadCallback Source #

Arguments

 = Message

message: the message

-> ClientContext

client: the client context

-> IO () 

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.

afterServerRequestRead :: (IsServer a, MonadIO m) => a -> ServerRequestReadCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestRead signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after server #requestRead callback

genClosure_ServerRequestRead :: MonadIO m => ServerRequestReadCallback -> m (GClosure C_ServerRequestReadCallback) Source #

Wrap the callback into a GClosure.

onServerRequestRead :: (IsServer a, MonadIO m) => a -> ServerRequestReadCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestRead signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on server #requestRead callback

requestStarted

type C_ServerRequestStartedCallback = Ptr () -> Ptr Message -> Ptr ClientContext -> Ptr () -> IO () Source #

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

type ServerRequestStartedCallback Source #

Arguments

 = Message

message: the new message

-> ClientContext

client: the client context

-> IO () 

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 Server::request_read signal. If a response is then sent, the request processing will end with a Server::request_finished signal. If a network error occurs, the processing will instead end with Server::request_aborted.

afterServerRequestStarted :: (IsServer a, MonadIO m) => a -> ServerRequestStartedCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestStarted signal, to be run after the default handler. When overloading is enabled, this is equivalent to

after server #requestStarted callback

onServerRequestStarted :: (IsServer a, MonadIO m) => a -> ServerRequestStartedCallback -> m SignalHandlerId Source #

Connect a signal handler for the requestStarted signal, to be run before the default handler. When overloading is enabled, this is equivalent to

on server #requestStarted callback