A %NULL-terminated array of URI schemes that should be
considered to be aliases for "http". Eg, if this included
The default value is an array containing the single element
See also #SoupServer:https-aliases.
A comma-delimited list of URI schemes that should be considered to be aliases for "https". See #SoupServer:http-aliases for more information.
The default value is %NULL, meaning that no URI schemes are considered aliases for "https".
The address of the network interface the server is listening on, if you are using the old #SoupServer API. (This will not be set if you use soup_server_listen(), etc.)
The port the server is listening on, if you are using the old #SoupServer API. (This will not be set if you use soup_server_listen(), etc.)
If non-%NULL, the value to use for the "Server" header on #SoupMessages 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 #SoupSession:user_agent, if you set a
#SoupServer:server_header property that has trailing whitespace,
#SoupServer will append its own product token (eg,
"
Path to a file containing a PEM-encoded certificate.
If you set this property and #SoupServer:ssl-key-file at construct time, then soup_server_new() will try to read the files; if it cannot, it will return %NULL, with no explicit indication of what went wrong (and logging a warning with newer versions of glib, since returning %NULL from a constructor is illegal).
Path to a file containing a PEM-encoded private key. See #SoupServer:ssl-cert-file for more information about how this is used.
A #GTlsCertificate that has a #GTlsCertificate: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 soup_server_set_ssl_cert_file() to have #SoupServer read in a a certificate from a file.
Add a new client stream to the server
.
a #GIOStream
the local #GSocketAddress associated with the stream
the remote #GSocketAddress associated with the stream
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.
a #SoupAuthDomain
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 #SoupAuthDomain or a signal handler), callback
will be invoked after receiving the request headers, but before
receiving the request body; the message's #SoupMessage:method and
#SoupMessage: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 soup_message_body_set_accumulate() on the message's #SoupMessage:request-body to turn off request-body accumulation, and connect to the message's #SoupMessage::got-chunk signal to process each chunk as it comes in.
To complete the message processing after the full message body has
been read, you can either also connect to #SoupMessage::got-body,
or else you can register a non-early handler for path
as well. As
long as you have not set the #SoupMessage:status-code by the time
#SoupMessage::got-body is emitted, the non-early handler will be
run as well.
the toplevel path for the handler
callback to invoke for requests under path
Adds a handler to server
for requests under path
. If path
is
%NULL 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 #SoupAuthDomain, an early #SoupServerHandler, or a
signal handler), callback
will be invoked after receiving the
request body; the message's #SoupMessage:method,
#SoupMessage:request-headers, and #SoupMessage:request-body fields
will be filled in.
After determining what to do with the request, the callback must at a minimum call soup_message_set_status() (or soup_message_set_status_full()) 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 soup_server_pause_message()
to tell server
to not send the response right away. When the
response is ready, call soup_server_unpause_message() to cause it
to be sent.
To send the response body a bit at a time using "chunked" encoding, first call soup_message_headers_set_encoding() to set %SOUP_ENCODING_CHUNKED on the #SoupMessage:response-headers. Then call soup_message_body_append() (or soup_message_body_append_buffer()) to append each chunk as it becomes ready, and soup_server_unpause_message() 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 soup_message_body_complete() to indicate that no more chunks are coming.
the toplevel path for the handler
callback to invoke for requests under path
Add support for a WebSocket extension of the given extension_type
.
When a WebSocket client requests an extension of extension_type,
a new #SoupWebsocketExtension of type extension_type
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 #SoupWebsocketExtensionDeflate is supported by default, use soup_server_remove_websocket_extension() if you want to disable it.
a #GType
Adds a WebSocket handler to server
for requests under path
. (If
path
is %NULL 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-%NULL, then only requests containing a matching
"Origin" header will be accepted. If protocols
is non-%NULL, 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.
the toplevel path for the handler
the origin of the connection
the protocols supported by this handler
callback to invoke for successful WebSocket requests under path
Creates a binding between source_property
on source
and target_property
on target
.
Whenever the source_property
is changed the target_property
is
updated using the same value. For instance:
g_object_bind_property (action, "active", widget, "sensitive", 0);
Will result in the "sensitive" property of the widget #GObject instance to be updated with the same value of the "active" property of the action #GObject instance.
If flags
contains %G_BINDING_BIDIRECTIONAL then the binding will be mutual:
if target_property
on target
changes then the source_property
on source
will be updated as well.
The binding will automatically be removed when either the source
or the
target
instances are finalized. To remove the binding without affecting the
source
and the target
you can just call g_object_unref() on the returned
#GBinding instance.
Removing the binding by calling g_object_unref() on it must only be done if
the binding, source
and target
are only used from a single thread and it
is clear that both source
and target
outlive the binding. Especially it
is not safe to rely on this if the binding, source
or target
can be
finalized from different threads. Keep another reference to the binding and
use g_binding_unbind() instead to be on the safe side.
A #GObject can have multiple bindings.
the property on source
to bind
the target #GObject
the property on target
to bind
flags to pass to #GBinding
Creates a binding between source_property
on source
and target_property
on target,
allowing you to set the transformation functions to be used by
the binding.
This function is the language bindings friendly version of g_object_bind_property_full(), using #GClosures instead of function pointers.
the property on source
to bind
the target #GObject
the property on target
to bind
flags to pass to #GBinding
a #GClosure wrapping the transformation function from the source
to the target,
or %NULL to use the default
a #GClosure wrapping the transformation function from the target
to the source,
or %NULL to use the default
Closes and frees server'
s listening sockets. If you are using the
old #SoupServer APIs, this also includes the effect of
soup_server_quit().
Note that if there are currently requests in progress on server,
that they will continue to be processed if server'
s #GMainContext
is still running.
You can call soup_server_listen(), etc, after calling this function if you want to start listening again.
This function is intended for #GObject implementations to re-enforce a [floating][floating-ref] object reference. Doing this is seldom required: all #GInitiallyUnowneds are created with a floating reference which usually just needs to be sunken by calling g_object_ref_sink().
Increases the freeze count on object
. If the freeze count is
non-zero, the emission of "notify" signals on object
is
stopped. The signals are queued until the freeze count is decreased
to zero. Duplicate notifications are squashed so that at most one
#GObject::notify signal is emitted for each property modified while the
object is frozen.
This is necessary for accessors that modify multiple properties to prevent premature notification while the object is still being modified.
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
#GMainContext, 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.
Gets a named field from the objects table of associations (see g_object_set_data()).
name of the key for that association
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 soup_server_get_listener(), this function returns #GSockets, not #SoupSockets.)
Gets the TCP port that server
is listening on, if you are using
the old API.
Gets a property of an object.
The value
can be:
In general, a copy is made of the property contents and the caller is responsible for freeing the memory by calling g_value_unset().
Note that g_object_get_property() is really intended for language bindings, g_object_get() is much more convenient for C programming.
the name of the property to get
return location for the property value
This function gets back user data pointers stored via g_object_set_qdata().
A #GQuark, naming the user data pointer
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 soup_server_listen_all(), the returned URIs
will use the addresses
Gets n_properties
properties for an object
.
Obtained properties will be set to values
. All properties must be valid.
Warnings will be emitted and undefined behaviour may result if invalid
properties are passed in.
the names of each property to get
the values of each property to get
Checks whether object
has a [floating][floating-ref] reference.
Checks whether server
is capable of https.
In order for a server to run https, you must call soup_server_set_ssl_cert_file(), or set the #SoupServer: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 #SoupServer serves https
exclusively. If you are using soup_server_listen(), etc, then a
%TRUE return value merely indicates that the server is
This attempts to set up server
to listen for connections on
address
.
If options
includes %SOUP_SERVER_LISTEN_HTTPS, 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 #GMainContext is
run.
Note that #SoupServer 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.
the address of the interface to listen on
listening options for this server
This attempts to set up server
to listen for connections on all
interfaces on the system. (That is, it listens on the addresses
options
includes %SOUP_SERVER_LISTEN_IPV4_ONLY,
%SOUP_SERVER_LISTEN_IPV6_ONLY, 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
soup_server_get_uris() to find out what port it ended up choosing.)
See soup_server_listen() for more details.
the port to listen on, or 0
listening options for this server
This attempts to set up server
to listen for connections on
fd
.
See soup_server_listen() for more details.
Note that server
will close fd
when you free it or call
soup_server_disconnect().
the file descriptor of a listening socket
listening options for this server
This attempts to set up server
to listen for connections on
"localhost" (that is, options
includes
%SOUP_SERVER_LISTEN_IPV4_ONLY, %SOUP_SERVER_LISTEN_IPV6_ONLY, 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 soup_server_get_uris() to find out what port it
ended up choosing.)
See soup_server_listen() for more details.
the port to listen on, or 0
listening options for this server
This attempts to set up server
to listen for connections on
socket
.
See soup_server_listen() for more details.
a listening #GSocket
listening options for this server
Emits a "notify" signal for the property property_name
on object
.
When possible, eg. when signaling a property change from within the class that registered the property, you should use g_object_notify_by_pspec() instead.
Note that emission of the notify signal may be blocked with g_object_freeze_notify(). In this case, the signal emissions are queued and will be emitted (in reverse order) when g_object_thaw_notify() is called.
the name of a property installed on the class of object
.
Emits a "notify" signal for the property specified by pspec
on object
.
This function omits the property name lookup, hence it is faster than g_object_notify().
One way to avoid using g_object_notify() from within the class that registered the properties, and using g_object_notify_by_pspec() instead, is to store the GParamSpec used with g_object_class_install_property() inside a static array, e.g.:
enum
{
PROP_0,
PROP_FOO,
PROP_LAST
};
static GParamSpec *properties[PROP_LAST];
static void
my_object_class_init (MyObjectClass *klass)
{
properties[PROP_FOO] = g_param_spec_int ("foo", "Foo", "The foo",
0, 100,
50,
G_PARAM_READWRITE);
g_object_class_install_property (gobject_class,
PROP_FOO,
properties[PROP_FOO]);
}
and then notify a change on the "foo" property with:
g_object_notify_by_pspec (self, properties[PROP_FOO]);
the #GParamSpec of a property installed on the class of object
.
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
soup_server_unpause_message() to resume I/O.
This must only be called on #SoupMessages which were created by the #SoupServer and are currently doing I/O, such as those passed into a #SoupServerCallback or emitted in a #SoupServer::request-read signal.
Stops processing for server,
if you are using the old API. Call
this to clean up after soup_server_run_async(), or to terminate a
call to soup_server_run().
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.
Increase the reference count of object,
and possibly remove the
[floating][floating-ref] reference, if object
has a floating reference.
In other words, if the object is floating, then this call "assumes ownership" of the floating reference, converting it to a normal reference by clearing the floating flag while leaving the reference count unchanged. If the object is not floating, then this call adds a new normal reference increasing the reference count by one.
Since GLib 2.56, the type of object
will be propagated to the return type
under the same conditions as for g_object_ref().
Removes auth_domain
from server
.
a #SoupAuthDomain
Removes all handlers (early and normal) registered at path
.
the toplevel path for the handler
Removes support for WebSocket extension of type extension_type
(or any subclass of
extension_type)
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.
a #GType
Starts server,
if you are using the old API, causing it to listen
for and process incoming connections. Unlike
soup_server_run_async(), this creates a #GMainLoop and runs it, and
it will not return until someone calls soup_server_quit() to stop
the server.
Starts server,
if you are using the old API, causing it to listen
for and process incoming connections.
The server runs in server'
s #GMainContext. 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
%SOUP_SERVER_ASYNC_CONTEXT property, this means the server will run
whenever the glib main loop is running.
Releases all references to other objects. This can be used to break reference cycles.
This function should only be called from object system implementations.
Each object carries around a table of associations from strings to pointers. This function lets you set an association.
If the object already had an association with that name, the old association will be destroyed.
Internally, the key
is converted to a #GQuark using g_quark_from_string().
This means a copy of key
is kept permanently (even after object
has been
finalized) — so it is recommended to only use a small, bounded set of values
for key
in your program, to avoid the #GQuark storage growing unbounded.
name of the key
data to associate with that key
Sets a property on an object.
the name of the property to set
the value
Sets server
up to do https, using the SSL/TLS certificate
specified by ssl_cert_file
and ssl_key_file
(which may point to
the same file).
Alternatively, you can set the #SoupServer:tls-certificate property at construction time, if you already have a #GTlsCertificate.
path to a file containing a PEM-encoded SSL/TLS certificate.
path to a file containing a PEM-encoded private key.
Remove a specified datum from the object's data associations, without invoking the association's destroy handler.
name of the key
This function gets back user data pointers stored via
g_object_set_qdata() and removes the data
from object
without invoking its destroy() function (if any was
set).
Usually, calling this function is only required to update
user data pointers with a destroy notifier, for example:
void
object_add_to_user_list (GObject *object,
const gchar *new_string)
{
// the quark, naming the object data
GQuark quark_string_list = g_quark_from_static_string ("my-string-list");
// retrieve the old string list
GList *list = g_object_steal_qdata (object, quark_string_list);
// prepend new string
list = g_list_prepend (list, g_strdup (new_string));
// this changed 'list', so we need to set it again
g_object_set_qdata_full (object, quark_string_list, list, free_string_list);
}
static void
free_string_list (gpointer data)
{
GList *node, *list = data;
for (node = list; node; node = node->next)
g_free (node->data);
g_list_free (list);
}
Using g_object_get_qdata() in the above example, instead of g_object_steal_qdata() would have left the destroy function set, and thus the partial string list would have been freed upon g_object_set_qdata_full().
A #GQuark, naming the user data pointer
Reverts the effect of a previous call to
g_object_freeze_notify(). The freeze count is decreased on object
and when it reaches zero, queued "notify" signals are emitted.
Duplicate notifications for each property are squashed so that at most one #GObject::notify signal is emitted for each property, in the reverse order in which they have been queued.
It is an error to call this function when the freeze count is zero.
Resumes I/O on msg
. Use this to resume after calling
soup_server_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 #SoupMessages which were created by the #SoupServer and are currently doing I/O, such as those passed into a #SoupServerCallback or emitted in a #SoupServer::request-read signal.
Decreases the reference count of object
. When its reference count
drops to 0, the object is finalized (i.e. its memory is freed).
If the pointer to the #GObject may be reused in future (for example, if it is an instance variable of another object), it is recommended to clear the pointer to %NULL rather than retain a dangling pointer to a potentially invalid #GObject instance. Use g_clear_object() for this.
This function essentially limits the life time of the closure
to
the life time of the object. That is, when the object is finalized,
the closure
is invalidated by calling g_closure_invalidate() on
it, in order to prevent invocations of the closure with a finalized
(nonexisting) object. Also, g_object_ref() and g_object_unref() are
added as marshal guards to the closure,
to ensure that an extra
reference count is held on object
during invocation of the
closure
. Usually, this function will be called on closures that
use this object
as closure data.
#GClosure to watch
Find the #GParamSpec with the given name for an
interface. Generally, the interface vtable passed in as g_iface
will be the default vtable from g_type_default_interface_ref(), or,
if you know the interface has already been loaded,
g_type_default_interface_peek().
any interface vtable for the interface, or the default vtable for the interface
name of a property to look up.
Add a property to an interface; this is only useful for interfaces that are added to GObject-derived types. Adding a property to an interface forces all objects classes with that interface to have a compatible property. The compatible property could be a newly created #GParamSpec, but normally g_object_class_override_property() will be used so that the object class only needs to provide an implementation and inherits the property description, default value, bounds, and so forth from the interface property.
This function is meant to be called from the interface's default
vtable initialization function (the class_init
member of
#GTypeInfo.) It must not be called after after class_init
has
been called for any object types implementing this interface.
If pspec
is a floating reference, it will be consumed.
any interface vtable for the interface, or the default vtable for the interface.
the #GParamSpec for the new property
Lists the properties of an interface.Generally, the interface
vtable passed in as g_iface
will be the default vtable from
g_type_default_interface_ref(), or, if you know the interface has
already been loaded, g_type_default_interface_peek().
any interface vtable for the interface, or the default vtable for the interface
Creates a new instance of a #GObject subtype and sets its properties.
Construction parameters (see %G_PARAM_CONSTRUCT, %G_PARAM_CONSTRUCT_ONLY) which are not explicitly specified are set to their default values.
the type id of the #GObject subtype to instantiate
an array of #GParameter
The server's #GMainContext, if you are using the old API. Servers created using soup_server_listen() will listen on the #GMainContext that was the thread-default context at the time soup_server_listen() was called.