### Class

# Soup Session

since: 3.0

#### Description [src]

    class Soup.Session : GObject.Object
    {
      /* No available fields */
    }

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 `SoupMessage` 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 `SoupSessionFeature` objects, which can be added to a session with `soup_session_add_feature()` or `soup_session_add_feature_by_type()` For example, `SoupLogger` provides support for logging HTTP traffic, `SoupContentDecoder` provides support for compressed response handling, and `SoupContentSniffer` provides support for HTML5-style response body content sniffing. Additionally, subtypes of `SoupAuth` can be added as features, to add support for additional authentication types.

All `SoupSession`s are created with a `SoupAuthManager`, 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 `SoupContentDecoder` by default.

Note that all async methods will invoke their callbacks on the thread-default context at the time of the function call.

Available since: 3.0

#### Ancestors

- GObject

#### Constructors

###### soup_session_new

Creates a `SoupSession` with the default options.

since: 3.0

###### soup_session_new_with_options

Creates a `SoupSession` with the specified options.

since: 3.0

#### Instance methods

###### soup_session_abort

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

since: 3.0

###### soup_session_add_feature

Adds `feature`‘s functionality to `session`. You cannot add multiple features of the same GLib.Type to a session.

since: 3.0

###### soup_session_add_feature_by_type

If `feature_type` is the type of a class that implements `SoupSessionFeature`, this creates a new feature of that type and adds it to `session` as with `soup_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.

since: 3.0

###### soup_session_get_accept_language

Get the value used by `session` for the “Accept-Language” header on new requests.

since: 3.0

###### soup_session_get_accept_language_auto

Gets whether `session` automatically sets the “Accept-Language” header on new requests.

since: 3.0

###### soup_session_get_async_result_message

Gets the `SoupMessage` of the `result` asynchronous operation This is useful to get the `SoupMessage` of an asynchronous operation started by `session` from its `GAsyncReadyCallback`.

since: 3.0

###### soup_session_get_feature

Gets the feature in `session` of type `feature_type`.

since: 3.0

###### soup_session_get_feature_for_message

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

since: 3.0

###### soup_session_get_idle_timeout

Get the timeout in seconds for idle connection lifetime currently used by `session`.

since: 3.0

###### soup_session_get_local_address

Get the `GInetSocketAddress` to use for the client side of connections in `session`.

since: 3.0

###### soup_session_get_max_conns

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

since: 3.0

###### soup_session_get_max_conns_per_host

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

since: 3.0

###### soup_session_get_proxy_resolver

Get the `GProxyResolver` currently used by `session`.

since: 3.0

###### soup_session_get_remote_connectable

Gets the remote connectable if one set.

since: 3.0

###### soup_session_get_timeout

Get the timeout in seconds for socket I/O operations currently used by `session`.

since: 3.0

###### soup_session_get_tls_database

Get the `GTlsDatabase` currently used by `session`.

since: 3.0

###### soup_session_get_tls_interaction

Get the `GTlsInteraction` currently used by `session`.

since: 3.0

###### soup_session_get_user_agent

Get the value used by `session` for the “User-Agent” header on new requests.

since: 3.0

###### soup_session_has_feature

Tests if `session` has at a feature of type `feature_type` (which can be the type of either a `SoupSessionFeature`, or else a subtype of some class managed by another feature, such as `SoupAuth`).

since: 3.0

###### soup_session_preconnect_async

Start a preconnection to `msg`.

since: 3.0

###### soup_session_preconnect_finish

Complete a preconnect async operation started with `soup_session_preconnect_async()`.

since: 3.0

###### soup_session_remove_feature

Removes `feature`‘s functionality from `session`.

since: 3.0

###### soup_session_remove_feature_by_type

Removes all features of type `feature_type` (or any subclass of `feature_type`) from `session`.

since: 3.0

###### soup_session_send

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

since: 3.0

###### soup_session_send_and_read

Synchronously sends `msg` and reads the response body.

since: 3.0

###### soup_session_send_and_read_async

Asynchronously sends `msg` and reads the response body.

since: 3.0

###### soup_session_send_and_read_finish

Gets the response to a `soup_session_send_and_read_async()`.

since: 3.0

###### soup_session_send_and_splice

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

since: 3.4

###### soup_session_send_and_splice_async

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.

since: 3.4

###### soup_session_send_and_splice_finish

Gets the response to a `soup_session_send_and_splice_async()`.

since: 3.4

###### soup_session_send_async

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

since: 3.0

###### soup_session_send_finish

Gets the response to a `soup_session_send_async()` call.

since: 3.0

###### soup_session_set_accept_language

Set the value to use for the “Accept-Language” header on `SoupMessage`s sent from `session`.

since: 3.0

###### soup_session_set_accept_language_auto

Set whether `session` will automatically set the “Accept-Language” header on requests using a value generated from system languages based on `g_get_language_names()`.

since: 3.0

###### soup_session_set_idle_timeout

Set a timeout in seconds for idle connection lifetime to be used by `session` on new connections.

since: 3.0

###### soup_session_set_proxy_resolver

Set a `GProxyResolver` to be used by `session` on new connections.

since: 3.0

###### soup_session_set_timeout

Set a timeout in seconds for socket I/O operations to be used by `session` on new connections.

since: 3.0

###### soup_session_set_tls_database

Set a GIo.TlsDatabase to be used by `session` on new connections.

since: 3.0

###### soup_session_set_tls_interaction

Set a `GTlsInteraction` to be used by `session` on new connections.

since: 3.0

###### soup_session_set_user_agent

Set the value to use for the “User-Agent” header on `SoupMessage`s sent from `session`.

since: 3.0

###### soup_session_websocket_connect_async

Asynchronously creates a `SoupWebsocketConnection` to communicate with a remote server.

since: 3.0

###### soup_session_websocket_connect_finish

Gets the `SoupWebsocketConnection` response to a `soup_session_websocket_connect_async()` call.

since: 3.0

##### Methods inherited from GObject (43)

Please see GObject for a full list of methods.

#### Properties

###### Soup.Session:accept-language

If non-`NULL`, the value to use for the “Accept-Language” header on `SoupMessage`s sent from this session.

since: 3.0

###### Soup.Session:accept-language-auto

If `TRUE`, `SoupSession` will automatically set the string for the “Accept-Language” header on every `SoupMessage` sent, based on the return value of `g_get_language_names()`.

since: 3.0

###### Soup.Session:idle-timeout

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

since: 3.0

###### Soup.Session:local-address

Sets the `GInetSocketAddress` to use for the client side of the connection.

since: 3.0

###### Soup.Session:max-conns

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

since: 3.0

###### Soup.Session:max-conns-per-host

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

since: 3.0

###### Soup.Session:proxy-resolver

A `GProxyResolver` to use with this session.

since: 3.0

###### Soup.Session:remote-connectable

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.

since: 3.0

###### Soup.Session:timeout

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

since: 3.0

###### Soup.Session:tls-database

Sets the `GTlsDatabase` to use for validating SSL/TLS certificates.

since: 3.0

###### Soup.Session:tls-interaction

A `GTlsInteraction` object that will be passed on to any `GTlsConnection`s created by the session.

since: 3.0

###### Soup.Session:user-agent

User-Agent string.

since: 3.0

#### Signals

###### Soup.Session::request-queued

Emitted when a request is queued on `session`.

since: 3.0

###### Soup.Session::request-unqueued

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

since: 3.0

##### Signals inherited from GObject (1)

###### GObject::notify

The notify signal is emitted on an object when one of its properties has its value set through g_object_set_property(), g_object_set(), et al.

since: 2.0

#### Class structure

    struct SoupSessionClass {
      GObjectClass parent_class;
      void (* request_queued) (
        SoupSession* session,
        SoupMessage* msg
      );
      void (* request_unqueued) (
        SoupSession* session,
        SoupMessage* msg
      );
      void (* _soup_reserved1) (
    void
      );
      void (* _soup_reserved2) (
    void
      );
      void (* _soup_reserved3) (
    void
      );
      void (* _soup_reserved4) (
    void
      );
      void (* _soup_reserved5) (
    void
      );
      void (* _soup_reserved6) (
    void
      );
      void (* _soup_reserved7) (
    void
      );
      void (* _soup_reserved8) (
    void
      );

    }

No description available.

###### Class members

`parent_class: GObjectClass`
  No description available.
`request_queued: void (* request_queued) ( SoupSession* session, SoupMessage* msg )`
  No description available.
`request_unqueued: void (* request_unqueued) ( SoupSession* session, SoupMessage* msg )`
  No description available.
`_soup_reserved1: void (* _soup_reserved1) ( void )`
  No description available.
`_soup_reserved2: void (* _soup_reserved2) ( void )`
  No description available.
`_soup_reserved3: void (* _soup_reserved3) ( void )`
  No description available.
`_soup_reserved4: void (* _soup_reserved4) ( void )`
  No description available.
`_soup_reserved5: void (* _soup_reserved5) ( void )`
  No description available.
`_soup_reserved6: void (* _soup_reserved6) ( void )`
  No description available.
`_soup_reserved7: void (* _soup_reserved7) ( void )`
  No description available.
`_soup_reserved8: void (* _soup_reserved8) ( void )`
  No description available.

#### Virtual methods

###### Soup.SessionClass.request_queued

No description available.

since: 3.0

###### Soup.SessionClass.request_unqueued

No description available.

since: 3.0