Copyright | Will Thompson and Iñaki García Etxebarria |
---|---|
License | LGPL-2.1 |
Maintainer | Iñaki García Etxebarria |
Safe Haskell | Safe-Inferred |
Language | Haskell2010 |
- Exported types
- Methods
- acceptIostream
- addAuthDomain
- addEarlyHandler
- addHandler
- addWebsocketExtension
- addWebsocketHandler
- disconnect
- getListeners
- getTlsAuthMode
- getTlsCertificate
- getTlsDatabase
- getUris
- isHttps
- listen
- listenAll
- listenLocal
- listenSocket
- pauseMessage
- removeAuthDomain
- removeHandler
- removeWebsocketExtension
- setTlsAuthMode
- setTlsCertificate
- setTlsDatabase
- unpauseMessage
- Properties
- Signals
A HTTP server.
Server
implements a simple HTTP server.
To begin, create a server using [ctorserver
.new]. Add at least one
handler by calling [methodserver
.add_handler] or
[methodserver
.add_early_handler]; 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
signalserver
[requestStarted] and then begin processing the request
as described below, but note that once the message is assigned a
status-code, then callbacks after that point will be
skipped. Note also that it is not defined when the callbacks happen
relative to various [classserverMessage
] signals.
Once the headers have been read, Server
will check if there is
a [classauthDomain
] (qv)
covering the Request-URI; if so, and if the
message does not contain suitable authorization, then the
[classauthDomain
] will set a status of StatusUnauthorized
on
the message.
After checking for authorization, Server
will look for "early"
handlers (added with [methodserver
.add_early_handler]) 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 Expect:
100-continue
, and a status code has been set, then
Server
will skip the remaining steps and return the response.
If the request headers contain Expect:
100-continue
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
[methodserver
.add_handler]) 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 [methodserverMessage
.pause]), 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 signalserver
[requestFinished] (or
signalserver
[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 set the [propertyserver
:tls-certificate]
property.
Once the server is set up, make one or more calls to
[methodserver
.listen], [methodserver
.listen_local], or
[methodserver
.listen_all] 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
SoupServer
s, 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
[structgLib
.MainContext].
Synopsis
- newtype Server = Server (ManagedPtr Server)
- class (GObject o, IsDescendantOf Server o) => IsServer o
- toServer :: (MonadIO m, IsServer o) => o -> m Server
- serverAcceptIostream :: (HasCallStack, MonadIO m, IsServer a, IsIOStream b, IsSocketAddress c, IsSocketAddress d) => a -> b -> Maybe c -> Maybe d -> m ()
- serverAddAuthDomain :: (HasCallStack, MonadIO m, IsServer a, IsAuthDomain b) => a -> b -> m ()
- serverAddEarlyHandler :: (HasCallStack, MonadIO m, IsServer a) => a -> Maybe Text -> ServerCallback -> m ()
- serverAddHandler :: (HasCallStack, MonadIO m, IsServer a) => a -> Maybe Text -> ServerCallback -> m ()
- serverAddWebsocketExtension :: (HasCallStack, MonadIO m, IsServer a) => a -> GType -> m ()
- serverAddWebsocketHandler :: (HasCallStack, MonadIO m, IsServer a) => a -> Maybe Text -> Maybe Text -> Maybe [Text] -> ServerWebsocketCallback -> m ()
- serverDisconnect :: (HasCallStack, MonadIO m, IsServer a) => a -> m ()
- serverGetListeners :: (HasCallStack, MonadIO m, IsServer a) => a -> m [Socket]
- serverGetTlsAuthMode :: (HasCallStack, MonadIO m, IsServer a) => a -> m TlsAuthenticationMode
- serverGetTlsCertificate :: (HasCallStack, MonadIO m, IsServer a) => a -> m (Maybe TlsCertificate)
- serverGetTlsDatabase :: (HasCallStack, MonadIO m, IsServer a) => a -> m (Maybe TlsDatabase)
- serverGetUris :: (HasCallStack, MonadIO m, IsServer a) => a -> m [Uri]
- serverIsHttps :: (HasCallStack, MonadIO m, IsServer a) => a -> m Bool
- serverListen :: (HasCallStack, MonadIO m, IsServer a, IsSocketAddress b) => a -> b -> [ServerListenOptions] -> m ()
- serverListenAll :: (HasCallStack, MonadIO m, IsServer a) => a -> Word32 -> [ServerListenOptions] -> m ()
- serverListenLocal :: (HasCallStack, MonadIO m, IsServer a) => a -> Word32 -> [ServerListenOptions] -> m ()
- serverListenSocket :: (HasCallStack, MonadIO m, IsServer a, IsSocket b) => a -> b -> [ServerListenOptions] -> m ()
- serverPauseMessage :: (HasCallStack, MonadIO m, IsServer a, IsServerMessage b) => a -> b -> m ()
- serverRemoveAuthDomain :: (HasCallStack, MonadIO m, IsServer a, IsAuthDomain b) => a -> b -> m ()
- serverRemoveHandler :: (HasCallStack, MonadIO m, IsServer a) => a -> Text -> m ()
- serverRemoveWebsocketExtension :: (HasCallStack, MonadIO m, IsServer a) => a -> GType -> m ()
- serverSetTlsAuthMode :: (HasCallStack, MonadIO m, IsServer a) => a -> TlsAuthenticationMode -> m ()
- serverSetTlsCertificate :: (HasCallStack, MonadIO m, IsServer a, IsTlsCertificate b) => a -> b -> m ()
- serverSetTlsDatabase :: (HasCallStack, MonadIO m, IsServer a, IsTlsDatabase b) => a -> b -> m ()
- serverUnpauseMessage :: (HasCallStack, MonadIO m, IsServer a, IsServerMessage b) => a -> b -> m ()
- constructServerRawPaths :: (IsServer o, MonadIO m) => Bool -> m (GValueConstruct o)
- getServerRawPaths :: (MonadIO m, IsServer o) => o -> m Bool
- clearServerServerHeader :: (MonadIO m, IsServer o) => o -> m ()
- constructServerServerHeader :: (IsServer o, MonadIO m) => Text -> m (GValueConstruct o)
- getServerServerHeader :: (MonadIO m, IsServer o) => o -> m (Maybe Text)
- setServerServerHeader :: (MonadIO m, IsServer o) => o -> Text -> m ()
- constructServerTlsAuthMode :: (IsServer o, MonadIO m) => TlsAuthenticationMode -> m (GValueConstruct o)
- getServerTlsAuthMode :: (MonadIO m, IsServer o) => o -> m TlsAuthenticationMode
- setServerTlsAuthMode :: (MonadIO m, IsServer o) => o -> TlsAuthenticationMode -> m ()
- constructServerTlsCertificate :: (IsServer o, MonadIO m, IsTlsCertificate a) => a -> m (GValueConstruct o)
- getServerTlsCertificate :: (MonadIO m, IsServer o) => o -> m (Maybe TlsCertificate)
- setServerTlsCertificate :: (MonadIO m, IsServer o, IsTlsCertificate a) => o -> a -> m ()
- constructServerTlsDatabase :: (IsServer o, MonadIO m, IsTlsDatabase a) => a -> m (GValueConstruct o)
- getServerTlsDatabase :: (MonadIO m, IsServer o) => o -> m (Maybe TlsDatabase)
- setServerTlsDatabase :: (MonadIO m, IsServer o, IsTlsDatabase a) => o -> a -> m ()
- type ServerRequestAbortedCallback = ServerMessage -> IO ()
- afterServerRequestAborted :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestAbortedCallback) -> m SignalHandlerId
- onServerRequestAborted :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestAbortedCallback) -> m SignalHandlerId
- type ServerRequestFinishedCallback = ServerMessage -> IO ()
- afterServerRequestFinished :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestFinishedCallback) -> m SignalHandlerId
- onServerRequestFinished :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestFinishedCallback) -> m SignalHandlerId
- type ServerRequestReadCallback = ServerMessage -> IO ()
- afterServerRequestRead :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestReadCallback) -> m SignalHandlerId
- onServerRequestRead :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestReadCallback) -> m SignalHandlerId
- type ServerRequestStartedCallback = ServerMessage -> IO ()
- afterServerRequestStarted :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestStartedCallback) -> m SignalHandlerId
- onServerRequestStarted :: (IsServer a, MonadIO m) => a -> ((?self :: a) => ServerRequestStartedCallback) -> m SignalHandlerId
Exported types
Memory-managed wrapper type.
Instances
Eq Server Source # | |
GObject Server Source # | |
Defined in GI.Soup.Objects.Server | |
ManagedPtrNewtype Server Source # | |
Defined in GI.Soup.Objects.Server toManagedPtr :: Server -> ManagedPtr Server | |
TypedObject Server Source # | |
Defined in GI.Soup.Objects.Server | |
HasParentTypes Server Source # | |
Defined in GI.Soup.Objects.Server | |
IsGValue (Maybe Server) Source # | Convert |
Defined in GI.Soup.Objects.Server gvalueGType_ :: IO GType gvalueSet_ :: Ptr GValue -> Maybe Server -> IO () gvalueGet_ :: Ptr GValue -> IO (Maybe Server) | |
type ParentTypes Server Source # | |
Defined in GI.Soup.Objects.Server type ParentTypes Server = '[Object] |
class (GObject o, IsDescendantOf Server o) => IsServer o Source #
Instances
(GObject o, IsDescendantOf Server o) => IsServer o Source # | |
Defined in GI.Soup.Objects.Server |
Methods
Click to display all available methods, including inherited ones
Methods
acceptIostream, addAuthDomain, addEarlyHandler, addHandler, addWebsocketExtension, addWebsocketHandler, bindProperty, bindPropertyFull, disconnect, forceFloating, freezeNotify, getv, isFloating, isHttps, listen, listenAll, listenLocal, listenSocket, notify, notifyByPspec, pauseMessage, ref, refSink, removeAuthDomain, removeHandler, removeWebsocketExtension, runDispose, stealData, stealQdata, thawNotify, unpauseMessage, unref, watchClosure.
Getters
getData, getListeners, getProperty, getQdata, getTlsAuthMode, getTlsCertificate, getTlsDatabase, getUris.
Setters
setData, setDataFull, setProperty, setTlsAuthMode, setTlsCertificate, setTlsDatabase.
acceptIostream
:: (HasCallStack, MonadIO m, IsServer a, IsIOStream b, IsSocketAddress c, IsSocketAddress d) | |
=> a |
|
-> b |
|
-> Maybe c |
|
-> Maybe d |
|
-> m () | (Can throw |
Adds a new client stream to the server
.
addAuthDomain
:: (HasCallStack, MonadIO m, IsServer a, IsAuthDomain b) | |
=> a |
|
-> b |
|
-> 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
SoupServer:100-continue Expectation, server
will reject it before the
request body is sent.
addEarlyHandler
serverAddEarlyHandler Source #
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> Maybe Text |
|
-> ServerCallback |
|
-> m () |
Adds an "early" handler to server
for requests prefixed by 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 [classauthDomain
] or a signal handler), callback
will be invoked after receiving the request headers, but before
receiving the request body; the message's method and
request-headers properties will be set.
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 [methodmessageBody
.set_accumulate] on
the message's request-body to turn off request-body accumulation, and connect
to the message's signalserverMessage
[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 signalserverMessage
[gotBody],
or else you can register a non-early handler for path
as well. As
long as you have not set the status-code by the time
signalserverMessage
[gotBody] is emitted, the non-early handler will be
run as well.
addHandler
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> Maybe Text |
|
-> ServerCallback |
|
-> m () |
Adds a handler to server
for requests prefixed by 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 [classauthDomain
], an early server handler, or a
signal handler), callback
will be invoked after receiving the
request body; the [classserverMessage
]'s method, request-headers,
and request-body properties will be set.
After determining what to do with the request, the callback must at a minimum
call [methodserverMessage
.set_status] 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 [methodserverMessage
.pause]
to tell server
to not send the response right away. When the
response is ready, call [methodserverMessage
.unpause] to cause it
to be sent.
To send the response body a bit at a time using "chunked" encoding, first
call [methodmessageHeaders
.set_encoding] to set EncodingChunked
on
the response-headers. Then call [methodmessageBody
.append] (or
[methodmessageBody
.append_bytes])) to append each chunk as it becomes ready,
and [methodserverMessage
.unpause] 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
[methodmessageBody
.complete] to indicate that no more chunks are coming.
addWebsocketExtension
serverAddWebsocketExtension Source #
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> GType |
|
-> m () |
Add support for a WebSocket extension of the given extensionType
.
When a WebSocket client requests an extension of extensionType
,
a new [classwebsocketExtension
] of type extensionType
will be created
to handle the request.
Note that [classwebsocketExtensionDeflate
] is supported by default, use
[methodserver
.remove_websocket_extension] if you want to disable it.
addWebsocketHandler
serverAddWebsocketHandler Source #
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> Maybe Text |
|
-> Maybe Text |
|
-> Maybe [Text] |
|
-> ServerWebsocketCallback |
|
-> m () |
Adds a WebSocket handler to server
for requests prefixed by 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 and
setting a failure status code if the handshake should be rejected.
disconnect
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> m () |
Closes and frees server
's listening sockets.
Note that if there are currently requests in progress on server
, that they
will continue to be processed if server
's [structgLib
.MainContext] is still
running.
You can call [methodserver
.listen], etc, after calling this function
if you want to start listening again.
getListeners
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> 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.
getTlsAuthMode
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> m TlsAuthenticationMode | Returns: a |
Gets the server
SSL/TLS client authentication mode.
getTlsCertificate
serverGetTlsCertificate Source #
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> m (Maybe TlsCertificate) | Returns: a |
Gets the server
SSL/TLS certificate.
getTlsDatabase
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> m (Maybe TlsDatabase) | Returns: a |
Gets the server
SSL/TLS database.
getUris
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> m [Uri] | Returns: a list of |
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 [methodserver
.listen_all] the returned URIs will use
the addresses 0.0.0.0
and ::
, rather than actually returning separate
URIs for each interface on the system.
isHttps
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> m Bool | Returns: |
Checks whether server
is capable of https.
In order for a server to run https, you must call
[methodserver
.set_tls_certificate], or set the
[propertyserver
: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 [methodserver
.listen], etc, then a True
return value merely indicates
that the server is *able* to do https, regardless of whether it actually
currently is or not. Use [methodserver
.get_uris] to see if it currently has
any https listeners.
listen
:: (HasCallStack, MonadIO m, IsServer a, IsSocketAddress b) | |
=> a |
|
-> b |
|
-> [ServerListenOptions] |
|
-> m () | (Can throw |
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 [structgLib
.MainContext] is run.
Note that this API does not make use of dual IPv4/IPv6 sockets; if
address
is an IPv6 address, it will only accept IPv6 connections.
You must configure IPv4 listening separately.
listenAll
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> Word32 |
|
-> [ServerListenOptions] |
|
-> m () | (Can throw |
Attempts to set up server
to listen for connections on all interfaces
on the system.
That is, it listens on the addresses 0.0.0.0
and/or ::
, 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 [methodserver
.get_uris] to find out
what port it ended up choosing.
See [methodserver
.listen] for more details.
listenLocal
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> Word32 |
|
-> [ServerListenOptions] |
|
-> m () | (Can throw |
Attempts to set up server
to listen for connections on "localhost".
That is, 127.0.0.1
and/or ::1
, 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
[methodserver
.get_uris] to find out what port it ended up choosing.
See [methodserver
.listen] for more details.
listenSocket
:: (HasCallStack, MonadIO m, IsServer a, IsSocket b) | |
=> a |
|
-> b |
|
-> [ServerListenOptions] |
|
-> m () | (Can throw |
Attempts to set up server
to listen for connections on socket
.
See [methodserver
.listen] for more details.
pauseMessage
:: (HasCallStack, MonadIO m, IsServer a, IsServerMessage b) | |
=> a |
|
-> b |
|
-> m () |
Deprecated: (Since version 3.2)Use serverMessagePause
instead.
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 [methodserver
.unpause_message] to
resume I/O.
This must only be called on a [classserverMessage
] which was created by the
Server
and are currently doing I/O, such as those passed into a
[callbackserverCallback
] or emitted in a signalserver
[requestRead]
signal.
removeAuthDomain
serverRemoveAuthDomain Source #
:: (HasCallStack, MonadIO m, IsServer a, IsAuthDomain b) | |
=> a |
|
-> b |
|
-> m () |
Removes authDomain
from server
.
removeHandler
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> Text |
|
-> m () |
Removes all handlers (early and normal) registered at path
.
removeWebsocketExtension
serverRemoveWebsocketExtension Source #
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> GType |
|
-> m () |
Removes support for WebSocket extension of type extensionType
(or any subclass of
extensionType
) from server
.
setTlsAuthMode
:: (HasCallStack, MonadIO m, IsServer a) | |
=> a |
|
-> TlsAuthenticationMode |
|
-> m () |
Sets server
's TlsAuthenticationMode
to use for SSL/TLS client authentication.
setTlsCertificate
serverSetTlsCertificate Source #
:: (HasCallStack, MonadIO m, IsServer a, IsTlsCertificate b) | |
=> a |
|
-> b |
|
-> m () |
Sets server
up to do https, using the given SSL/TLS certificate
.
setTlsDatabase
:: (HasCallStack, MonadIO m, IsServer a, IsTlsDatabase b) | |
=> a |
|
-> b |
|
-> m () |
Sets server
's TlsDatabase
to use for validating SSL/TLS client certificates.
unpauseMessage
:: (HasCallStack, MonadIO m, IsServer a, IsServerMessage b) | |
=> a |
|
-> b |
|
-> m () |
Deprecated: (Since version 3.2)Use serverMessageUnpause
instead.
Resumes I/O on msg
.
Use this to resume after calling [methodserver
.pause_message], 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 a [classserverMessage
] which was created by the
Server
and are currently doing I/O, such as those passed into a
[callbackserverCallback
] or emitted in a signalserver
[requestRead]
signal.
Properties
rawPaths
If True
, percent-encoding in the Request-URI path will not be
automatically decoded.
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
Server header.
If non-Nothing
, the value to use for the "Server" header on
[classserverMessage
]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 [propertysession
:user_agent], if you set a
[propertyserver
:server-header] property that has trailing
whitespace, Server
will append its own product token (eg,
libsoup/2.3.2
) 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 ]
tlsAuthMode
A TlsAuthenticationMode
for SSL/TLS client authentication.
constructServerTlsAuthMode :: (IsServer o, MonadIO m) => TlsAuthenticationMode -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “tls-auth-mode
” property. This is rarely needed directly, but it is used by new
.
getServerTlsAuthMode :: (MonadIO m, IsServer o) => o -> m TlsAuthenticationMode Source #
Get the value of the “tls-auth-mode
” property.
When overloading is enabled, this is equivalent to
get
server #tlsAuthMode
setServerTlsAuthMode :: (MonadIO m, IsServer o) => o -> TlsAuthenticationMode -> m () Source #
Set the value of the “tls-auth-mode
” property.
When overloading is enabled, this is equivalent to
set
server [ #tlsAuthMode:=
value ]
tlsCertificate
A [classgio
.TlsCertificate[] that has a
TlsCertificate:privateKey set.
If this is set, then the server will be able to speak https in addition to (or instead of) plain http.
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
setServerTlsCertificate :: (MonadIO m, IsServer o, IsTlsCertificate a) => o -> a -> m () Source #
Set the value of the “tls-certificate
” property.
When overloading is enabled, this is equivalent to
set
server [ #tlsCertificate:=
value ]
tlsDatabase
A TlsDatabase
to use for validating SSL/TLS client
certificates.
constructServerTlsDatabase :: (IsServer o, MonadIO m, IsTlsDatabase a) => a -> m (GValueConstruct o) Source #
Construct a GValueConstruct
with valid value for the “tls-database
” property. This is rarely needed directly, but it is used by new
.
getServerTlsDatabase :: (MonadIO m, IsServer o) => o -> m (Maybe TlsDatabase) Source #
Get the value of the “tls-database
” property.
When overloading is enabled, this is equivalent to
get
server #tlsDatabase
setServerTlsDatabase :: (MonadIO m, IsServer o, IsTlsDatabase a) => o -> a -> m () Source #
Set the value of the “tls-database
” property.
When overloading is enabled, this is equivalent to
set
server [ #tlsDatabase:=
value ]
Signals
requestAborted
type ServerRequestAbortedCallback Source #
= ServerMessage |
|
-> IO () |
Emitted when processing has failed for a message.
This could mean either that it could not be read (if
signalserver
[requestRead] has not been emitted for it yet), or that
the response could not be written back (if signalserver
[requestRead]
has been emitted but signalserver
[requestFinished] 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
signalserver
[requestStarted].
afterServerRequestAborted :: (IsServer a, MonadIO m) => a -> ((?self :: 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
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onServerRequestAborted :: (IsServer a, MonadIO m) => a -> ((?self :: 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 ServerRequestFinishedCallback Source #
= ServerMessage |
|
-> IO () |
Emitted when the server has finished writing a response to a request.
afterServerRequestFinished :: (IsServer a, MonadIO m) => a -> ((?self :: 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
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onServerRequestFinished :: (IsServer a, MonadIO m) => a -> ((?self :: 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 ServerRequestReadCallback Source #
= ServerMessage |
|
-> 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 -> ((?self :: 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
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onServerRequestRead :: (IsServer a, MonadIO m) => a -> ((?self :: 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 ServerRequestStartedCallback Source #
= ServerMessage |
|
-> 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 signalserver
[request_read signal]. If a
response is then sent, the request processing will end with
a signalserver
[requestFinished] signal. If a network error
occurs, the processing will instead end with
signalserver
[requestAborted].
afterServerRequestStarted :: (IsServer a, MonadIO m) => a -> ((?self :: 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
By default the object invoking the signal is not passed to the callback.
If you need to access it, you can use the implit ?self
parameter.
Note that this requires activating the ImplicitParams
GHC extension.
onServerRequestStarted :: (IsServer a, MonadIO m) => a -> ((?self :: 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