WebResource#
Superclasses: Object
Represents a resource at the end of a URI.
A WebResource
encapsulates content for each resource at the
end of a particular URI. For example, one 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
WebResource
, using get_uri()
and
get_response()
, as well as the raw data, using
get_data()
.
Methods#
- class WebResource
- get_data(cancellable: Cancellable | None = None, callback: Callable[[Object | None, AsyncResult, Any], None] | None = None, user_data: Any = None) None #
Asynchronously get the raw data for
resource
.When the operation is finished,
callback
will be called. You can then callget_data_finish()
to get the result of the operation.- Parameters:
cancellable – a
Cancellable
orNone
to ignorecallback – a
AsyncReadyCallback
to call when the request is satisfieduser_data – the data to pass to callback function
- get_data_finish(result: AsyncResult) list[int] #
Finish an asynchronous operation started with
get_data()
.- Parameters:
result – a
AsyncResult
- get_response() URIResponse #
Retrieves the
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() str #
Returns the current active URI of
resource
.The active URI might change during a load operation:
<orderedlist> <listitem><para>
When the resource load starts, the active URI is the requested URI
</para></listitem> <listitem><para>
When the initial request is sent to the server,
WebResource
::sent-request signal is emitted without a redirected response, the active URI is the URI of the request sent to the server.</para></listitem> <listitem><para>
In case of a server redirection,
WebResource
::sent-request signal is emitted again with a redirected response, the active URI is the URI the request was redirected to.</para></listitem> <listitem><para>
When the response is received from the server, the active URI is the final one and it will not change again.
</para></listitem> </orderedlist>
You can monitor the active URI by connecting to the notify::uri signal of
resource
.
Properties#
- class WebResource
- props.response: URIResponse#
The type of the None singleton.
Signals#
- class WebResource.signals
- failed(error: GError) None #
The type of the None singleton.
- Parameters:
error – the
Error
that was triggered
- failed_with_tls_errors(certificate: TlsCertificate, errors: TlsCertificateFlags) None #
The type of the None singleton.
Added in version 2.8.
- Parameters:
certificate – a
TlsCertificate
errors – a
TlsCertificateFlags
with the verification status ofcertificate
- sent_request(request: URIRequest, redirected_response: URIResponse) None #
The type of the None singleton.
- Parameters:
request – a
URIRequest
redirected_response – a
URIResponse
, orNone