Soup session state object.
Session is the object that controls client-side HTTP. A Session encapsulates all of the
state that libsoup is keeping on behalf of your program; cached HTTP connections, authentication information, etc. It also keeps track of
various global options and features that you are using.
Most applications will only need a single Session; the primary reason you might need multiple sessions is if you
need to have multiple independent authentication contexts. (Eg, you are connecting to a server and authenticating as two different users at
different times; the easiest way to ensure that each [class@Message] is sent with the authentication information you intended is to use one
session for the first user, and a second session for the other user.)
Additional Session functionality is provided by [iface@SessionFeature] objects, which can be added to a session with
[method@Session.add_feature] or [method@Session.add_feature_by_type] For example, [class@Logger] provides support for logging HTTP traffic, [
class@ContentDecoder] provides support for compressed response handling, and [class@ContentSniffer] provides support for HTML5-style response
body content sniffing. Additionally, subtypes of [class@Auth] can be added as features, to add support for additional authentication types.
All `SoupSession`s are created with a [class@AuthManager], and support for soup_type_auth_basic and
soup_type_auth_digest. Additionally, sessions using the plain Session class (rather
than one of its deprecated subtypes) have a [class@ContentDecoder] by default.
Note that all async methods will invoke their callbacks on the thread-default context at the time of the function call.
- public void abort ()
Cancels all pending requests in this and
closes all idle persistent connections.
- public void add_feature (SessionFeature feature)
Adds feature
's functionality to this
.
- public void add_feature_by_type (Type feature_type)
If feature_type
is the type of a class that implements [
iface@SessionFeature], this creates a new feature of that type and adds it to this as with [
method@Session.
- public unowned string? get_accept_language ()
Get the value used by this for the
"Accept-Language" header on new requests.
- public bool get_accept_language_auto ()
Gets whether this automatically sets the
"Accept-Language" header on new requests.
- public unowned Message? get_async_result_message (AsyncResult result)
Gets the [class@Message] of the result
asynchronous operation
This is useful to get the [class@Message] of an asynchronous operation started by this from its [
callback@Gio.
- public unowned SessionFeature? get_feature (Type feature_type)
Gets the feature in this of type
feature_type
.
- public unowned SessionFeature? get_feature_for_message (Type feature_type, Message msg)
Gets the feature in this of type
feature_type
, provided that it is not disabled for msg
.
- public uint get_idle_timeout ()
Get the timeout in seconds for idle connection lifetime currently used by
this.
- public unowned InetSocketAddress? get_local_address ()
Get the [class@Gio.
- public uint get_max_conns ()
Get the maximum number of connections that this
can open at once.
- public uint get_max_conns_per_host ()
Get the maximum number of connections that this
can open at once to a given host.
- public unowned ProxyResolver? get_proxy_resolver ()
Get the [iface@Gio.
- public unowned SocketConnectable? get_remote_connectable ()
Gets the remote connectable if one set.
- public uint get_timeout ()
Get the timeout in seconds for socket I/O operations currently used by
this.
- public unowned TlsDatabase? get_tls_database ()
Get the [class@Gio.
- public unowned TlsInteraction? get_tls_interaction ()
Get the [class@Gio.
- public unowned string? get_user_agent ()
Get the value used by this for the
"User-Agent" header on new requests.
- public bool has_feature (Type feature_type)
Tests if this has at a feature of type
feature_type
(which can be the type of either a [iface@SessionFeature], or else a subtype of some class managed by another
feature, such as [class@Auth]).
- public async bool preconnect_async (Message msg, int io_priority, Cancellable? cancellable) throws Error
Start a preconnection to msg
.
- public void remove_feature (SessionFeature feature)
Removes feature
's functionality from
this.
- public void remove_feature_by_type (Type feature_type)
Removes all features of type feature_type
(or any subclass of
feature_type
) from this.
- public InputStream send (Message msg, Cancellable? cancellable = null) throws Error
Synchronously sends msg
and waits for the beginning of a
response.
- public Bytes send_and_read (Message msg, Cancellable? cancellable = null) throws Error
Synchronously sends msg
and reads the response body.
- public async Bytes send_and_read_async (Message msg, int io_priority, Cancellable? cancellable) throws Error
Asynchronously sends msg
and reads the response body.
- public ssize_t send_and_splice (Message msg, OutputStream out_stream, OutputStreamSpliceFlags flags, Cancellable? cancellable = null) throws Error
Synchronously sends msg
and splices the response body stream
into out_stream
.
- public async ssize_t send_and_splice_async (Message msg, OutputStream out_stream, OutputStreamSpliceFlags flags, int io_priority, Cancellable? cancellable) throws Error
Asynchronously sends msg
and splices the response body stream
into out_stream
.
- public async InputStream send_async (Message msg, int io_priority, Cancellable? cancellable) throws Error
Asynchronously sends msg
and waits for the beginning of a
response.
- public void set_accept_language (string accept_language)
Set the value to use for the "Accept-Language" header on [class@Message]s
sent from this.
- public void set_accept_language_auto (bool accept_language_auto)
Set whether this will automatically set
the "Accept-Language" header on requests using a value generated from system languages based on [func@GLib.
- public void set_idle_timeout (uint timeout)
Set a timeout in seconds for idle connection lifetime to be used by
this on new connections.
- public void set_proxy_resolver (ProxyResolver? proxy_resolver)
Set a [iface@Gio.
- public void set_timeout (uint timeout)
Set a timeout in seconds for socket I/O operations to be used by
this on new connections.
- public void set_tls_database (TlsDatabase? tls_database)
Set a [class@GIo.
- public void set_tls_interaction (TlsInteraction? tls_interaction)
Set a [class@Gio.
- public void set_user_agent (string user_agent)
Set the value to use for the "User-Agent" header on [class@Message]s sent
from this.
- public async WebsocketConnection websocket_connect_async (Message msg, string? origin, string[]? protocols, int io_priority, Cancellable? cancellable) throws Error
Asynchronously creates a [class@WebsocketConnection] to communicate with a
remote server.