Session

open class Session(pointer: <Error class: unknown class><<Error class: unknown class>>)

Soup session state object.

#SoupSession is the object that controls client-side HTTP. A #SoupSession 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 #SoupSession; 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 #SoupSession 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 SoupSessions are created with a class@AuthManager, and support for %SOUP_TYPE_AUTH_BASIC and %SOUP_TYPE_AUTH_DIGEST. Additionally, sessions using the plain #SoupSession 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.

Skipped during bindings generation

  • method accept-language: Property TypeInfo of getter and setter do not match

  • method user-agent: Property TypeInfo of getter and setter do not match

  • constructor new_with_options: Varargs parameter is not supported

Constructors

Link copied to clipboard
constructor()

Creates a #SoupSession with the default options.

constructor(pointer: <Error class: unknown class><<Error class: unknown class>>)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

If true, #SoupSession will automatically set the string for the "Accept-Language" header on every class@Message sent, based on the return value of func@GLib.get_language_names.

Link copied to clipboard
open var idleTimeout: <Error class: unknown class>

Connection lifetime (in seconds) when idle. Any connection left idle longer than this will be closed.

Link copied to clipboard
open val localAddress: <Error class: unknown class>?

Sets the class@Gio.InetSocketAddress to use for the client side of the connection.

Link copied to clipboard
open val maxConns: <Error class: unknown class>

The maximum number of connections that the session can open at once.

Link copied to clipboard
open val maxConnsPerHost: <Error class: unknown class>

The maximum number of connections that the session can open at once to a given host.

Link copied to clipboard
open var proxyResolver: <Error class: unknown class>?

A iface@Gio.ProxyResolver to use with this session.

Link copied to clipboard
open val remoteConnectable: <Error class: unknown class>?

Sets a socket to make outgoing connections on. This will override the default behaviour of opening TCP/IP sockets to the hosts specified in the URIs.

Link copied to clipboard
val soupSessionPointer: <Error class: unknown class><<Error class: unknown class>>
Link copied to clipboard
open var timeout: <Error class: unknown class>

The timeout (in seconds) for socket I/O operations (including connecting to a server, and waiting for a reply to an HTTP request).

Link copied to clipboard
open var tlsDatabase: <Error class: unknown class>?

Sets the class@Gio.TlsDatabase to use for validating SSL/TLS certificates.

Link copied to clipboard
open var tlsInteraction: <Error class: unknown class>?

A class@Gio.TlsInteraction object that will be passed on to any class@Gio.TlsConnections created by the session.

Functions

Link copied to clipboard
open fun abort()

Cancels all pending requests in @session and closes all idle persistent connections.

Link copied to clipboard
open fun addFeature(feature: SessionFeature)

Adds @feature's functionality to @session. You cannot add multiple features of the same alias@GObject.Type to a session.

Link copied to clipboard
open fun addFeatureByType(featureType: <Error class: unknown class>)

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 @session as with method@Session.add_feature. You can use this when you don't need to customize the new feature in any way. Adding multiple features of the same @feature_type is not allowed.

Link copied to clipboard
fun connectRequestQueued(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (msg: Message) -> Unit): <Error class: unknown class>

Emitted when a request is queued on @session.

Link copied to clipboard
fun connectRequestUnqueued(connectFlags: <Error class: unknown class> = ConnectFlags(0u), handler: (msg: Message) -> Unit): <Error class: unknown class>

Emitted when a request is removed from @session's queue, indicating that @session is done with it.

Link copied to clipboard

Get the value used by @session for the "Accept-Language" header on new requests.

Link copied to clipboard
open fun getAsyncResultMessage(result: <Error class: unknown class>): Message?

Gets the class@Message of the @result asynchronous operation This is useful to get the class@Message of an asynchronous operation started by @session from its callback@Gio.AsyncReadyCallback.

Link copied to clipboard
open fun getFeature(featureType: <Error class: unknown class>): SessionFeature?

Gets the feature in @session of type @feature_type.

Link copied to clipboard
open fun getFeatureForMessage(featureType: <Error class: unknown class>, msg: Message): SessionFeature?

Gets the feature in @session of type @feature_type, provided that it is not disabled for @msg.

Link copied to clipboard
open fun getUserAgent(): String?

Get the value used by @session for the "User-Agent" header on new requests.

Link copied to clipboard
open fun hasFeature(featureType: <Error class: unknown class>): Boolean

Tests if @session 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).

Link copied to clipboard
open fun preconnectAsync(msg: Message, ioPriority: <Error class: unknown class>, cancellable: <Error class: unknown class>? = null, callback: <Error class: unknown class>?)

Start a preconnection to @msg.

Link copied to clipboard
open fun preconnectFinish(result: <Error class: unknown class>): <Error class: unknown class><Boolean>

Complete a preconnect async operation started with method@Session.preconnect_async.

Link copied to clipboard
open fun removeFeature(feature: SessionFeature)

Removes @feature's functionality from @session.

Link copied to clipboard
open fun removeFeatureByType(featureType: <Error class: unknown class>)

Removes all features of type @feature_type (or any subclass of

Link copied to clipboard
open fun send(msg: Message, cancellable: <Error class: unknown class>? = null): <Error class: unknown class><<Error class: unknown class>>

Synchronously sends @msg and waits for the beginning of a response.

Link copied to clipboard
open fun sendAndRead(msg: Message, cancellable: <Error class: unknown class>? = null): <Error class: unknown class><<Error class: unknown class>>

Synchronously sends @msg and reads the response body.

Link copied to clipboard
open fun sendAndReadAsync(msg: Message, ioPriority: <Error class: unknown class>, cancellable: <Error class: unknown class>? = null, callback: <Error class: unknown class>?)

Asynchronously sends @msg and reads the response body.

Link copied to clipboard
open fun sendAndReadFinish(result: <Error class: unknown class>): <Error class: unknown class><<Error class: unknown class>>

Gets the response to a method@Session.send_and_read_async.

Link copied to clipboard
open fun sendAndSplice(msg: Message, outStream: <Error class: unknown class>, flags: <Error class: unknown class>, cancellable: <Error class: unknown class>? = null): <Error class: unknown class><Long>

Synchronously sends @msg and splices the response body stream into @out_stream.

Link copied to clipboard
open fun sendAndSpliceAsync(msg: Message, outStream: <Error class: unknown class>, flags: <Error class: unknown class>, ioPriority: <Error class: unknown class>, cancellable: <Error class: unknown class>? = null, callback: <Error class: unknown class>?)

Asynchronously sends @msg and splices the response body stream into @out_stream. When @callback is called, then either @msg has been sent and its response body spliced, or else an error has occurred.

Link copied to clipboard
open fun sendAndSpliceFinish(result: <Error class: unknown class>): <Error class: unknown class><Long>

Gets the response to a method@Session.send_and_splice_async.

Link copied to clipboard
open fun sendAsync(msg: Message, ioPriority: <Error class: unknown class>, cancellable: <Error class: unknown class>? = null, callback: <Error class: unknown class>?)

Asynchronously sends @msg and waits for the beginning of a response.

Link copied to clipboard
open fun sendFinish(result: <Error class: unknown class>): <Error class: unknown class><<Error class: unknown class>>

Gets the response to a method@Session.send_async call.

Link copied to clipboard
open fun setAcceptLanguage(acceptLanguage: String)

Set the value to use for the "Accept-Language" header on class@Messages sent from @session.

Link copied to clipboard
open fun setUserAgent(userAgent: String)

Set the value to use for the "User-Agent" header on class@Messages sent from @session.

Link copied to clipboard
open fun websocketConnectAsync(msg: Message, origin: String? = null, protocols: List<String>? = null, ioPriority: <Error class: unknown class>, cancellable: <Error class: unknown class>? = null, callback: <Error class: unknown class>?)

Asynchronously creates a class@WebsocketConnection to communicate with a remote server.

Link copied to clipboard
open fun websocketConnectFinish(result: <Error class: unknown class>): <Error class: unknown class><WebsocketConnection>

Gets the class@WebsocketConnection response to a method@Session.websocket_connect_async call.