Class WebResource
- All Implemented Interfaces:
Proxy
A WebKitWebResource
encapsulates content for each resource at the
end of a particular URI. For example, one WebKitWebResource
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
WebKitWebResource
, using webkit_web_resource_get_uri() and
webkit_web_resource_get_response(), as well as the raw data, using
webkit_web_resource_get_data().
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
WebResource.Builder<B extends WebResource.Builder<B>>
Inner class implementing a builder pattern to construct a GObject with properties.static interface
Functional interface declaration of theFailedCallback
callback.static interface
Functional interface declaration of theFailedWithTlsErrorsCallback
callback.static interface
Functional interface declaration of theFinishedCallback
callback.static interface
Functional interface declaration of theSentRequestCallback
callback.static class
Nested classes/interfaces inherited from class org.gnome.gobject.GObject
GObject.NotifyCallback, GObject.ObjectClass
-
Constructor Summary
ConstructorDescriptionWebResource
(MemorySegment address) Create a WebResource proxy instance for the provided memory address. -
Method Summary
Modifier and TypeMethodDescriptionprotected WebResource
asParent()
Returns this instance as if it were its parent type.static WebResource.Builder
<? extends WebResource.Builder> builder()
AWebResource.Builder
object constructs aWebResource
with the specified properties.void
emitFailed
(GError error) Emits the "failed" signal.void
emitFailedWithTlsErrors
(TlsCertificate certificate, Set<TlsCertificateFlags> errors) Emits the "failed-with-tls-errors" signal.void
Emits the "finished" signal.void
emitSentRequest
(URIRequest request, URIResponse redirectedResponse) Emits the "sent-request" signal.void
getData
(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback) Asynchronously get the raw data for this WebResource.byte[]
getDataFinish
(AsyncResult result) Finish an asynchronous operation started with webkit_web_resource_get_data().Retrieves theWebKitURIResponse
of the resource load operation.static Type
getType()
Get the GType of the WebResource classgetUri()
Returns the current active URI of this WebResource.onFailed
(WebResource.FailedCallback handler) This signal is emitted when an error occurs during the resource load operation.This signal is emitted when a TLS error occurs during the resource load operation.onFinished
(WebResource.FinishedCallback handler) This signal is emitted when the resource load finishes successfully or due to an error.This signal is emitted whenrequest
has been sent to the server.Methods inherited from class org.gnome.gobject.GObject
addToggleRef, addWeakPointer, bindProperty, bindProperty, bindProperty, bindPropertyFull, bindPropertyFull, bindPropertyWithClosures, bindPropertyWithClosures, compatControl, connect, connect, connect, constructed, disconnect, dispatchPropertiesChanged, dispose, dupData, dupQdata, emit, emitNotify, finalize_, forceFloating, freezeNotify, get, getData, getMemoryLayout, getProperty, getProperty, getProperty, getQdata, getv, interfaceFindProperty, interfaceInstallProperty, interfaceListProperties, isFloating, newInstance, newInstance, newInstance, newInstance, newv, notify_, notify_, notifyByPspec, onNotify, ref, refSink, removeToggleRef, removeWeakPointer, replaceData, replaceQdata, runDispose, set, setData, setDataFull, setProperty, setProperty, setProperty, setQdata, setQdataFull, setv, stealData, stealQdata, takeRef, thawNotify, unref, watchClosure, weakRef, weakUnref, withProperties
Methods inherited from class org.gnome.gobject.TypeInstance
callParent, callParent, getPrivate, readGClass, writeGClass
Methods inherited from class io.github.jwharm.javagi.base.ProxyInstance
equals, handle, hashCode
-
Constructor Details
-
WebResource
Create a WebResource proxy instance for the provided memory address.- Parameters:
address
- the memory address of the native object
-
-
Method Details
-
getType
-
asParent
Returns this instance as if it were its parent type. This is mostly synonymous to the Javasuper
keyword, but will set the native typeclass function pointers to the parent type. When overriding a native virtual method in Java, "chaining up" withsuper.methodName()
doesn't work, because it invokes the overridden function pointer again. To chain up, callasParent().methodName()
. This will call the native function pointer of this virtual method in the typeclass of the parent type. -
getData
public void getData(@Nullable @Nullable Cancellable cancellable, @Nullable @Nullable AsyncReadyCallback callback) Asynchronously get the raw data for this WebResource.When the operation is finished,
callback
will be called. You can then call webkit_web_resource_get_data_finish() to get the result of the operation.- Parameters:
cancellable
- aGCancellable
ornull
to ignorecallback
- aGAsyncReadyCallback
to call when the request is satisfied
-
getDataFinish
Finish an asynchronous operation started with webkit_web_resource_get_data().- Parameters:
result
- aGAsyncResult
- Returns:
- a
string with the data of this WebResource, or
null
in case of error. iflength
is notnull
, the size of the data will be assigned to it. - Throws:
GErrorException
- seeGError
-
getResponse
Retrieves theWebKitURIResponse
of the resource load operation.This method returns
null
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.- Returns:
- the
WebKitURIResponse
, ornull
if the response hasn't been received yet.
-
getUri
Returns the current active URI of this WebResource.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,
WebKitWebResource
::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,WebKitWebResource
::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 this WebResource.
- Returns:
- the current active URI of this WebResource
-
onFailed
This signal is emitted when an error occurs during the resource load operation.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitFailed
Emits the "failed" signal. SeeonFailed(org.gnome.webkit.WebResource.FailedCallback)
. -
onFailedWithTlsErrors
public SignalConnection<WebResource.FailedWithTlsErrorsCallback> onFailedWithTlsErrors(WebResource.FailedWithTlsErrorsCallback handler) This signal is emitted when a TLS error occurs during the resource load operation.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitFailedWithTlsErrors
Emits the "failed-with-tls-errors" signal. SeeonFailedWithTlsErrors(org.gnome.webkit.WebResource.FailedWithTlsErrorsCallback)
. -
onFinished
public SignalConnection<WebResource.FinishedCallback> onFinished(WebResource.FinishedCallback handler) This signal is emitted when the resource load finishes successfully or due to an error. In case of errorsWebKitWebResource
::failed signal is emitted before this one.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitFinished
public void emitFinished()Emits the "finished" signal. SeeonFinished(org.gnome.webkit.WebResource.FinishedCallback)
. -
onSentRequest
public SignalConnection<WebResource.SentRequestCallback> onSentRequest(WebResource.SentRequestCallback handler) This signal is emitted whenrequest
has been sent to the server. In case of a server redirection this signal is emitted again with therequest
argument containing the new request sent to the server due to the redirection and theredirectedResponse
parameter containing the response received by the server for the initial request.- Parameters:
handler
- the signal handler- Returns:
- a signal handler ID to keep track of the signal connection
- See Also:
-
emitSentRequest
Emits the "sent-request" signal. SeeonSentRequest(org.gnome.webkit.WebResource.SentRequestCallback)
. -
builder
AWebResource.Builder
object constructs aWebResource
with the specified properties. Use the variousset...()
methods to set properties, and finish construction withWebResource.Builder.build()
.
-