EDataServer.SoupSession

g EDataServer.SoupSession EDataServer.SoupSession GObject.Object GObject.Object Soup.Session Soup.Session GObject.Object->Soup.Session Soup.Session->EDataServer.SoupSession

Subclasses:EDataServer.WebDAVSession

Methods

Inherited:Soup.Session (33), GObject.Object (37)
Structs:GObject.ObjectClass (5)
class new (source)
class util_status_to_string (status_code, reason_phrase)
  check_result (request, read_bytes, bytes_length)
  dup_credentials ()
  get_authentication_requires_credentials ()
  get_log_level ()
  get_source ()
  get_ssl_error_details ()
  new_request (method, uri_string)
  new_request_uri (method, uri)
  send_request_simple_sync (request, cancellable)
  send_request_sync (request, cancellable)
  set_credentials (credentials)
  setup_logging (logging_level)

Virtual Methods

Inherited:Soup.Session (9), GObject.Object (7)

Properties

Inherited:Soup.Session (20)
Name Type Flags Short Description
credentials EDataServer.NamedParameters r/w/en  
source EDataServer.Source r/w/co  

Fields

Inherited:Soup.Session (6), GObject.Object (1)
Name Type Access Description
parent Soup.Session r  

Class Details

class EDataServer.SoupSession(**kwargs)
Bases:Soup.Session
Abstract:No
Structure:EDataServer.SoupSessionClass

Contains only private data that should be read and manipulated using the functions below.

New in version 3.26.

classmethod new(source)
Parameters:source (EDataServer.Source) – an EDataServer.Source
Returns:a new EDataServer.SoupSession; free it with GObject.Object.unref(), when no longer needed.
Return type:EDataServer.SoupSession

Creates a new EDataServer.SoupSession associated with given source. The source can be used to store and read SSL trust settings, but only if it already contains an EDataServer.SourceWebdav extension. Otherwise the SSL trust settings are ignored.

New in version 3.26.

classmethod util_status_to_string(status_code, reason_phrase)
Parameters:
  • status_code (int) – an HTTP status code
  • reason_phrase (str or None) – preferred string to use for the message, or None
Returns:

Error text based on given arguments. The returned value is valid as long as reason_phrase is not freed.

Return type:

str

Returns the reason_phrase, if it’s non-None and non-empty, a static string corresponding to status_code. In case neither that can be found a localized “Unknown error” message is returned.

New in version 3.26.

check_result(request, read_bytes, bytes_length)
Parameters:
Raises:

GLib.Error

Returns:

Whether succeeded, aka True, when no error recognized and False otherwise.

Return type:

bool

Checks result of the request and sets the error if it failed. When it failed and the read_bytes is provided, then these are set to request’s message response_body, thus it can be used later.

New in version 3.26.

dup_credentials()
Returns:A copy of the credentials being previously set with EDataServer.SoupSession.set_credentials(), or None when none are set. Free the returned pointer with EDataServer.NamedParameters.free(), when no longer needed.
Return type:EDataServer.NamedParameters or None

New in version 3.26.

get_authentication_requires_credentials()
Returns:Whether the last connection attempt required any credentials. Authentications like OAuth2 do not want extra credentials to work.
Return type:bool

New in version 3.28.

get_log_level()
Returns:Current log level, as Soup.LoggerLogLevel
Return type:Soup.LoggerLogLevel

New in version 3.26.

get_source()
Returns:Associated EDataServer.Source with the self.
Return type:EDataServer.Source

New in version 3.26.

get_ssl_error_details()
Returns:Whether the information was available and set to the out parameters.
out_certificate_pem:
 return location for a server TLS/SSL certificate in PEM format, when the last operation failed with a TLS/SSL error
out_certificate_errors:
 return location for a Gio.TlsCertificateFlags, with certificate error flags when the the operation failed with a TLS/SSL error
Return type:(bool, out_certificate_pem: str, out_certificate_errors: Gio.TlsCertificateFlags)

Populates out_certificate_pem and out_certificate_errors with the last values returned on Soup.Status.SSL_FAILED error.

New in version 3.26.

new_request(method, uri_string)
Parameters:
  • method (str) – an HTTP method
  • uri_string (str) – a URI string to use for the request
Raises:

GLib.Error

Returns:

a new Soup.RequestHTTP, or None on error

Return type:

Soup.RequestHTTP

Creates a new Soup.RequestHTTP, similar to Soup.Session.request_http(), but also presets request headers with “User-Agent” to be “Evolution/version” and with “Connection” to be “close”.

See also EDataServer.SoupSession.new_request_uri().

New in version 3.26.

new_request_uri(method, uri)
Parameters:
Raises:

GLib.Error

Returns:

a new Soup.RequestHTTP, or None on error

Return type:

Soup.RequestHTTP

Creates a new Soup.RequestHTTP, similar to Soup.Session.request_http_uri(), but also presets request headers with “User-Agent” to be “Evolution/version” and with “Connection” to be “close”.

See also EDataServer.SoupSession.new_request().

New in version 3.26.

send_request_simple_sync(request, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

A newly allocated GLib.ByteArray, which contains whole content from the URI pointed to by request.

Return type:

bytes

Similar to EDataServer.SoupSession.send_request_sync(), except it reads whole response content into memory and returns it as a GLib.ByteArray. Use EDataServer.SoupSession.send_request_sync() when you want to have more control on the content read.

The function prints read content to stdout when EDataServer.SoupSession.get_log_level() returns Soup.LoggerLogLevel.BODY.

New in version 3.26.

send_request_sync(request, cancellable)
Parameters:
Raises:

GLib.Error

Returns:

A newly allocated Gio.InputStream, that can be used to read from the URI pointed to by request. Free it with GObject.Object.unref(), when no longer needed.

Return type:

Gio.InputStream

Synchronously sends prepared request and returns Gio.InputStream that can be used to read its contents.

This calls Soup.Request.send() internally, but it also setups the request according to EDataServer.SoupSession :source authentication settings. It also extracts information about used certificate, in case of Soup.Status.SSL_FAILED error and keeps it for later use by EDataServer.SoupSession.get_ssl_error_details().

Use EDataServer.SoupSession.send_request_simple_sync() to read whole content into a GLib.ByteArray.

Note that Soup.Session doesn’t log content read from Gio.InputStream, thus the caller may print the read content on its own when needed.

Note the request is fully filled only after there is anything read from the resulting Gio.InputStream, thus use EDataServer.SoupSession.check_result() to verify that the receive had been finished properly.

New in version 3.26.

set_credentials(credentials)
Parameters:credentials (EDataServer.NamedParameters or None) – an EDataServer.NamedParameters with credentials to use, or None

Sets credentials to use for connection. Using None for credentials unsets previous value.

New in version 3.26.

setup_logging(logging_level)
Parameters:logging_level (str or None) – logging level to setup, or None

Setups logging for the self. The logging_level can be one of: “all” - log whole raw communication; “body” - the same as “all”; “headers” - log the headers only; “min” - minimal logging; “1” - the same as “all”. Any other value, including None, disables logging.

Use EDataServer.SoupSession.get_log_level() to get current log level.

New in version 3.26.

Property Details

EDataServer.SoupSession.props.credentials
Name:credentials
Type:EDataServer.NamedParameters
Default Value:None
Flags:READABLE, WRITABLE, EXPLICIT_NOTIFY

The EDataServer.NamedParameters containing login credentials.

New in version 3.26.

EDataServer.SoupSession.props.source
Name:source
Type:EDataServer.Source
Default Value:None
Flags:READABLE, WRITABLE, CONSTRUCT_ONLY

The EDataServer.Source being used for this soup session.

New in version 3.26.