GrlNet.Wc

g GObject.Object GObject.Object GrlNet.Wc GrlNet.Wc GObject.Object->GrlNet.Wc

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

error_quark ()

class

new ()

flush_delayed_requests ()

request_async (uri, cancellable, callback, *user_data)

request_finish (result)

request_with_headers_async (uri, headers, cancellable, callback, *user_data)

set_cache (use_cache)

set_cache_size (cache_size)

set_log_level (log_level)

set_throttling (throttling)

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

cache

bool

r/w/c

Use cache

cache-size

int

r/w/c

Size of cache in Mb

loglevel

int

r/w

Log level for HTTP connections

throttling

int

r/w

Time to throttle connections

user-agent

str

r/w/c

User agent identifier

Signals

Inherited:

GObject.Object (1)

Fields

Inherited:

GObject.Object (1)

Class Details

class GrlNet.Wc(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

GrlNet.WcClass

classmethod error_quark()
Return type:

int

classmethod new()
Returns:

a new allocated instance of GrlNet.Wc. Do GObject.Object.unref() after use it.

Return type:

GrlNet.Wc

Creates a new GrlNet.Wc.

flush_delayed_requests()

This method will flush all the pending request in the queue.

request_async(uri, cancellable, callback, *user_data)
Parameters:

Request the fetching of a web resource given the uri. This request is asynchronous, thus the result will be returned within the callback.

request_finish(result)
Parameters:

result (Gio.AsyncResult) – The result of the request

Raises:

GLib.Error

Returns:

True if the request was successfull. If False an error occurred.

content:

The contents of the resource

Return type:

(bool, content: bytes)

Finishes an asynchronous load of the file’s contents. The contents are placed in contents, and length is set to the size of the contents string.

The content address will be invalidated at the next request. So if you want to keep it, please copy it into another address.

request_with_headers_async(uri, headers, cancellable, callback, *user_data)
Parameters:

Request the fetching of a web resource given the uri. This request is asynchronous, thus the result will be returned within the callback.

New in version 0.2.2.

set_cache(use_cache)
Parameters:

use_cache (bool) – if cache must be used or not

Sets if cache must be used. Note that this will only work if caching is supporting. If sets True, a new cache will be created. If sets to False, current cache is clean and removed.

New in version 0.1.12.

set_cache_size(cache_size)
Parameters:

cache_size (int) – size of cache (in Mb)

Sets the new maximum size of cache, in Megabytes. Default value is 10. Using 0 means no cache will be done.

New in version 0.1.12.

set_log_level(log_level)
Parameters:

log_level (int) – the libsoup log level to set [0,3]

Setting the log level the logger feature is added into the libsoup session.

set_throttling(throttling)
Parameters:

throttling (int) – the number of seconds to wait between requests

Setting this property, the GrlNet.Wc will queue all the requests and will dispatch them with a pause between them of this value.

Note that if the grl-net library was compiled against libsoup3, changing the throttling configuration will show a warning if done after the first request.

Property Details

GrlNet.Wc.props.cache
Name:

cache

Type:

bool

Default Value:

True

Flags:

READABLE, WRITABLE, CONSTRUCT

Use cache

GrlNet.Wc.props.cache_size
Name:

cache-size

Type:

int

Default Value:

10

Flags:

READABLE, WRITABLE, CONSTRUCT

Size of cache in Mb

GrlNet.Wc.props.loglevel
Name:

loglevel

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Log level for HTTP connections

GrlNet.Wc.props.throttling
Name:

throttling

Type:

int

Default Value:

0

Flags:

READABLE, WRITABLE

Time to throttle connections

GrlNet.Wc.props.user_agent
Name:

user-agent

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT

User agent identifier