:right-sidebar: True WebResource =================================================================== .. currentmodule:: gi.repository.WebKit .. class:: WebResource(**properties: ~typing.Any) :no-contents-entry: Superclasses: :class:`~gi.repository.GObject.Object` Represents a resource at the end of a URI. A :obj:`~gi.repository.WebKit.WebResource` encapsulates content for each resource at the end of a particular URI. For example, one :obj:`~gi.repository.WebKit.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 :obj:`~gi.repository.WebKit.WebResource`\, using :func:`~gi.repository.WebKit.WebResource.get_uri` and :func:`~gi.repository.WebKit.WebResource.get_response`, as well as the raw data, using :func:`~gi.repository.WebKit.WebResource.get_data`. Methods ------- .. rst-class:: interim-class .. class:: WebResource :no-index: .. method:: get_data(cancellable: ~gi.repository.Gio.Cancellable | None = None, callback: ~typing.Callable[[~gi.repository.GObject.Object | None, ~gi.repository.Gio.AsyncResult, ~typing.Any], None] | None = None, user_data: ~typing.Any = None) -> None Asynchronously get the raw data for ``resource``\. When the operation is finished, ``callback`` will be called. You can then call :func:`~gi.repository.WebKit.WebResource.get_data_finish` to get the result of the operation. :param cancellable: a :obj:`~gi.repository.Gio.Cancellable` or :const:`None` to ignore :param callback: a :obj:`~gi.repository.Gio.AsyncReadyCallback` to call when the request is satisfied :param user_data: the data to pass to callback function .. method:: get_data_finish(result: ~gi.repository.Gio.AsyncResult) -> list[int] Finish an asynchronous operation started with :func:`~gi.repository.WebKit.WebResource.get_data`. :param result: a :obj:`~gi.repository.Gio.AsyncResult` .. method:: get_response() -> ~gi.repository.WebKit.URIResponse Retrieves the :obj:`~gi.repository.WebKit.URIResponse` of the resource load operation. This method returns :const:`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. .. method:: get_uri() -> str Returns the current active URI of ``resource``\. 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, :obj:`~gi.repository.WebKit.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, :obj:`~gi.repository.WebKit.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 ``resource``\. Properties ---------- .. rst-class:: interim-class .. class:: WebResource :no-index: .. attribute:: props.response :type: ~gi.repository.WebKit.URIResponse The type of the None singleton. .. attribute:: props.uri :type: str The type of the None singleton. Signals ------- .. rst-class:: interim-class .. class:: WebResource.signals :no-index: .. method:: failed(error: ~gi.repository.GLib.GError) -> None The type of the None singleton. :param error: the :obj:`~gi.repository.GLib.Error` that was triggered .. method:: failed_with_tls_errors(certificate: ~gi.repository.Gio.TlsCertificate, errors: ~gi.repository.Gio.TlsCertificateFlags) -> None The type of the None singleton. .. versionadded:: 2.8 :param certificate: a :obj:`~gi.repository.Gio.TlsCertificate` :param errors: a :obj:`~gi.repository.Gio.TlsCertificateFlags` with the verification status of ``certificate`` .. method:: finished() -> None The type of the None singleton. .. method:: sent_request(request: ~gi.repository.WebKit.URIRequest, redirected_response: ~gi.repository.WebKit.URIResponse) -> None The type of the None singleton. :param request: a :obj:`~gi.repository.WebKit.URIRequest` :param redirected_response: a :obj:`~gi.repository.WebKit.URIResponse`\, or :const:`None`