WebKit.NetworkSession

g GObject.Object GObject.Object WebKit.NetworkSession WebKit.NetworkSession GObject.Object->WebKit.NetworkSession

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

get_default ()

class

new (data_directory, cache_directory)

class

new_ephemeral ()

class

set_memory_pressure_settings (settings)

allow_tls_certificate_for_host (certificate, host)

download_uri (uri)

get_cookie_manager ()

get_itp_enabled ()

get_itp_summary (cancellable, callback, *user_data)

get_itp_summary_finish (result)

get_persistent_credential_storage_enabled ()

get_tls_errors_policy ()

get_website_data_manager ()

is_ephemeral ()

prefetch_dns (hostname)

set_itp_enabled (enabled)

set_persistent_credential_storage_enabled (enabled)

set_proxy_settings (proxy_mode, proxy_settings)

set_tls_errors_policy (policy)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

cache-directory

str

w/co

data-directory

str

w/co

is-ephemeral

bool

r/w/co

Signals

Inherited:

GObject.Object (1)

Name

Short Description

download-started

This signal is emitted when a new download request is made.

Fields

Inherited:

GObject.Object (1)

Class Details

class WebKit.NetworkSession(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

WebKit.NetworkSessionClass

Manages network configuration.

New in version 2.40.

classmethod get_default()
Returns:

a WebKit.NetworkSession

Return type:

WebKit.NetworkSession

Get the default network session. The default network session is created using WebKit.NetworkSession.new() and passing None as data and cache directories.

New in version 2.40.

classmethod new(data_directory, cache_directory)
Parameters:
  • data_directory (str or None) – a base directory for data, or None

  • cache_directory (str or None) – a base directory for caches, or None

Returns:

the newly created WebKit.NetworkSession

Return type:

WebKit.NetworkSession

Creates a new WebKit.NetworkSession with a persistent WebKit.WebsiteDataManager. The parameters data_directory and cache_directory will be used as construct properties of the WebKit.WebsiteDataManager of the network session. Note that if None is passed, the default directory will be passed to WebKit.WebsiteDataManager so that WebKit.WebsiteDataManager.get_base_data_directory() and WebKit.WebsiteDataManager.get_base_cache_directory() always return a value for non ephemeral sessions.

It must be passed as construct parameter of a WebKit.WebView.

New in version 2.40.

classmethod new_ephemeral()
Returns:

a new ephemeral WebKit.NetworkSession.

Return type:

WebKit.NetworkSession

Creates a new WebKit.NetworkSession with an ephemeral WebKit.WebsiteDataManager.

New in version 2.40.

classmethod set_memory_pressure_settings(settings)
Parameters:

settings (WebKit.MemoryPressureSettings) – a WebKit.MemoryPressureSettings.

Sets settings as the WebKit.MemoryPressureSettings.

Sets settings as the WebKit.MemoryPressureSettings to be used by the network process created by any instance of WebKit.NetworkSession after this function is called.

Be sure to call this function before creating any WebKit.NetworkSession.

The periodic check for used memory is disabled by default on network processes. This will be enabled only if custom settings have been set using this function. After that, in order to remove the custom settings and disable the periodic check, this function must be called passing None as the value of settings.

New in version 2.40.

allow_tls_certificate_for_host(certificate, host)
Parameters:

Ignore further TLS errors on the host for the certificate present in info.

If host is an IPv6 address, it should not be surrounded by brackets. This expectation matches GLib.Uri.get_host().

New in version 2.40.

download_uri(uri)
Parameters:

uri (str) – the URI to download

Returns:

a new WebKit.Download representing the download operation.

Return type:

WebKit.Download

Requests downloading of the specified URI string.

The download operation will not be associated to any WebKit.WebView, if you are interested in starting a download from a particular WebKit.WebView use WebKit.WebView.download_uri() instead.

New in version 2.40.

Returns:

a WebKit.CookieManager

Return type:

WebKit.CookieManager

Get the WebKit.CookieManager of self.

New in version 2.40.

get_itp_enabled()
Returns:

True if ITP is enabled, or False otherwise.

Return type:

bool

Get whether Intelligent Tracking Prevention (ITP) is enabled or not.

New in version 2.40.

get_itp_summary(cancellable, callback, *user_data)
Parameters:

Asynchronously get the list of WebKit.ITPThirdParty seen for self.

Every WebKit.ITPThirdParty contains the list of WebKit.ITPFirstParty under which it has been seen.

When the operation is finished, callback will be called. You can then call WebKit.NetworkSession.get_itp_summary_finish() to get the result of the operation.

New in version 2.40.

get_itp_summary_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a GLib.List of WebKit.ITPThirdParty. You must free the GLib.List with g_list_free() and unref the WebKit.ITPThirdParty s with WebKit.ITPThirdParty.unref() when you’re done with them.

Return type:

[WebKit.ITPThirdParty]

Finish an asynchronous operation started with WebKit.NetworkSession.get_itp_summary().

New in version 2.40.

get_persistent_credential_storage_enabled()
Returns:

True if persistent credential storage is enabled, or False otherwise.

Return type:

bool

Get whether persistent credential storage is enabled or not.

See also WebKit.NetworkSession.set_persistent_credential_storage_enabled().

New in version 2.40.

get_tls_errors_policy()
Returns:

a WebKit.TLSErrorsPolicy

Return type:

WebKit.TLSErrorsPolicy

Get the TLS errors policy of self.

New in version 2.40.

get_website_data_manager()
Returns:

a WebKit.WebsiteDataManager

Return type:

WebKit.WebsiteDataManager

Get the WebKit.WebsiteDataManager of self.

New in version 2.40.

is_ephemeral()
Returns:

True if self is pehmeral, or False otherwise

Return type:

bool

Get whether self is ephemeral. A WebKit.NetworkSession is ephemeral when its WebKit.WebsiteDataManager is ephemeral. See WebKit.WebsiteDataManager :is-ephemeral for more details.

New in version 2.40.

prefetch_dns(hostname)
Parameters:

hostname (str) – a hostname to be resolved

Resolve the domain name of the given hostname in advance, so that if a URI of hostname is requested the load will be performed more quickly.

New in version 2.40.

set_itp_enabled(enabled)
Parameters:

enabled (bool) – value to set

Enable or disable Intelligent Tracking Prevention (ITP).

When ITP is enabled resource load statistics are collected and used to decide whether to allow or block third-party cookies and prevent user tracking. Note that while ITP is enabled the accept policy WebKit.CookieAcceptPolicy.NO_THIRD_PARTY is ignored and WebKit.CookieAcceptPolicy.ALWAYS is used instead. See also webkit_cookie_session_set_accept_policy().

New in version 2.40.

set_persistent_credential_storage_enabled(enabled)
Parameters:

enabled (bool) – value to set

Enable or disable persistent credential storage.

When enabled, which is the default for non-ephemeral sessions, the network process will try to read and write HTTP authentiacation credentials from persistent storage.

New in version 2.40.

set_proxy_settings(proxy_mode, proxy_settings)
Parameters:

Set the network proxy settings to be used by connections started in self session.

By default WebKit.NetworkProxyMode.DEFAULT is used, which means that the system settings will be used (Gio.ProxyResolver.get_default()). If you want to override the system default settings, you can either use WebKit.NetworkProxyMode.NO_PROXY to make sure no proxies are used at all, or WebKit.NetworkProxyMode.CUSTOM to provide your own proxy settings. When proxy_mode is WebKit.NetworkProxyMode.CUSTOM proxy_settings must be a valid WebKit.NetworkProxySettings; otherwise, proxy_settings must be None.

New in version 2.40.

set_tls_errors_policy(policy)
Parameters:

policy (WebKit.TLSErrorsPolicy) – a WebKit.TLSErrorsPolicy

Set the TLS errors policy of self as policy.

New in version 2.40.

Signal Details

WebKit.NetworkSession.signals.download_started(network_session, download)
Signal Name:

download-started

Flags:

RUN_LAST

Parameters:

This signal is emitted when a new download request is made.

New in version 2.40.

Property Details

WebKit.NetworkSession.props.cache_directory
Name:

cache-directory

Type:

str

Default Value:

None

Flags:

WRITABLE, CONSTRUCT_ONLY

The base caches directory used to create the WebKit.WebsiteDataManager. If None, a default location will be used.

New in version 2.40.

WebKit.NetworkSession.props.data_directory
Name:

data-directory

Type:

str

Default Value:

None

Flags:

WRITABLE, CONSTRUCT_ONLY

The base data directory used to create the WebKit.WebsiteDataManager. If None, a default location will be used.

New in version 2.40.

WebKit.NetworkSession.props.is_ephemeral
Name:

is-ephemeral

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Whether to create an ephermeral WebKit.WebsiteDataManager for the session.

New in version 2.40.