WebKit2.WebResource

g GObject.Object GObject.Object WebKit2.WebResource WebKit2.WebResource GObject.Object->WebKit2.WebResource

Subclasses:

None

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

get_data (cancellable, callback, *user_data)

get_data_finish (result)

get_response ()

get_uri ()

Virtual Methods

Inherited:

GObject.Object (7)

Properties

Name

Type

Flags

Short Description

response

WebKit2.URIResponse

r

uri

str

r

Signals

Inherited:

GObject.Object (1)

Name

Short Description

failed

This signal is emitted when an error occurs during the resource load operation.

failed-with-tls-errors

This signal is emitted when a TLS error occurs during the resource load operation.

finished

This signal is emitted when the resource load finishes successfully or due to an error.

received-data

This signal is emitted after response is received, every time new data has been received. deprecated

sent-request

This signal is emitted when request has been sent to the server.

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

parent

GObject.Object

r

Class Details

class WebKit2.WebResource(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

WebKit2.WebResourceClass

Represents a resource at the end of a URI.

A WebKit2.WebResource encapsulates content for each resource at the end of a particular URI. For example, one WebKit2.WebResource will be created for each separate image and stylesheet when a page is loaded.

You can access the response and the URI for a given WebKit2.WebResource, using WebKit2.WebResource.get_uri() and WebKit2.WebResource.get_response(), as well as the raw data, using WebKit2.WebResource.get_data().

get_data(cancellable, callback, *user_data)
Parameters:

Asynchronously get the raw data for self.

When the operation is finished, callback will be called. You can then call WebKit2.WebResource.get_data_finish() to get the result of the operation.

get_data_finish(result)
Parameters:

result (Gio.AsyncResult) – a Gio.AsyncResult

Raises:

GLib.Error

Returns:

a string with the data of self, or None in case of error. if length is not None, the size of the data will be assigned to it.

Return type:

bytes

Finish an asynchronous operation started with WebKit2.WebResource.get_data().

get_response()
Returns:

the WebKit2.URIResponse, or None if the response hasn’t been received yet.

Return type:

WebKit2.URIResponse

Retrieves the WebKit2.URIResponse of the resource load operation.

This method returns None if called before the response is received from the server. You can connect to notify::response signal to be notified when the response is received.

get_uri()
Returns:

the current active URI of self

Return type:

str

Returns the current active URI of self.

The active URI might change during a load operation:

When the resource load starts, the active URI is the requested URI

When the initial request is sent to the server, WebKit2.WebResource ::sent-request signal is emitted without a redirected response, the active URI is the URI of the request sent to the server.

In case of a server redirection, WebKit2.WebResource ::sent-request signal is emitted again with a redirected response, the active URI is the URI the request was redirected to.

When the response is received from the server, the active URI is the final one and it will not change again.

You can monitor the active URI by connecting to the notify::uri signal of self.

Signal Details

WebKit2.WebResource.signals.failed(web_resource, error)
Signal Name:

failed

Flags:

RUN_LAST

Parameters:

This signal is emitted when an error occurs during the resource load operation.

WebKit2.WebResource.signals.failed_with_tls_errors(web_resource, certificate, errors)
Signal Name:

failed-with-tls-errors

Flags:

RUN_LAST

Parameters:

This signal is emitted when a TLS error occurs during the resource load operation.

New in version 2.8.

WebKit2.WebResource.signals.finished(web_resource)
Signal Name:

finished

Flags:

RUN_LAST

Parameters:

web_resource (WebKit2.WebResource) – The object which received the signal

This signal is emitted when the resource load finishes successfully or due to an error. In case of errors WebKit2.WebResource ::failed signal is emitted before this one.

WebKit2.WebResource.signals.received_data(web_resource, data_length)
Signal Name:

received-data

Flags:

RUN_LAST

Parameters:
  • web_resource (WebKit2.WebResource) – The object which received the signal

  • data_length (int) – the length of data received in bytes

This signal is emitted after response is received, every time new data has been received. It’s useful to know the progress of the resource load operation.

This is signal is deprecated since version 2.40 and it’s never emitted.

Deprecated since version 2.40.

WebKit2.WebResource.signals.sent_request(web_resource, request, redirected_response)
Signal Name:

sent-request

Flags:

RUN_LAST

Parameters:

This signal is emitted when request has been sent to the server. In case of a server redirection this signal is emitted again with the request argument containing the new request sent to the server due to the redirection and the redirected_response parameter containing the response received by the server for the initial request.

Property Details

WebKit2.WebResource.props.response
Name:

response

Type:

WebKit2.URIResponse

Default Value:

None

Flags:

READABLE

The WebKit2.URIResponse associated with this resource.

WebKit2.WebResource.props.uri
Name:

uri

Type:

str

Default Value:

None

Flags:

READABLE

The current active URI of the WebKit2.WebResource. See WebKit2.WebResource.get_uri() for more details.