Class WebResource

All Implemented Interfaces:
Proxy

@Generated("org.javagi.JavaGI") public final class WebResource extends GObject

Represents a resource at the end of a URI.

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().

  • Constructor Details

    • WebResource

      public WebResource(MemorySegment address)
      Create a WebResource instance for the provided memory address.
      Parameters:
      address - the memory address of the native object
    • WebResource

      public WebResource()
      Create a new WebResource.
  • Method Details

    • getType

      public static @Nullable Type getType()
      Get the GType of the WebResource class.
      Returns:
      the GType
    • getMemoryLayout

      public static MemoryLayout getMemoryLayout()
      The memory layout of the native struct.
      Returns:
      the memory layout
    • asParent

      protected WebResource asParent()
      Return this instance as if it were its parent type. Comparable to the Java super keyword, but ensures the parent typeclass is also used in native code.
      Overrides:
      asParent in class GObject
      Returns:
      the instance as if it were its parent type
    • getData

      public void getData(@Nullable Cancellable cancellable, @Nullable AsyncReadyCallback callback)

      Asynchronously get the raw data for resource.

      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 - a GCancellable or null to ignore
      callback - a GAsyncReadyCallback to call when the request is satisfied
    • getDataFinish

      public byte[] getDataFinish(AsyncResult result) throws GErrorException
      Finish an asynchronous operation started with webkit_web_resource_get_data().
      Parameters:
      result - a GAsyncResult
      Returns:
      a string with the data of resource, or null in case of error. if length is not null, the size of the data will be assigned to it.
      Throws:
      GErrorException - see GError
    • getResponse

      public URIResponse getResponse()

      Retrieves the WebKitURIResponse 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, or null if the response hasn't been received yet.
    • getUri

      public String getUri()

      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, `WebKitWebResource`::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, `WebKitWebResource`::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.

      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

      public void emitFailed(@Nullable GError error)
      Emits the "failed" signal. See onFailed(WebResource.FailedCallback).
    • onFailedWithTlsErrors

      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
      Since:
      2.8
      See Also:
    • emitFailedWithTlsErrors

      public void emitFailedWithTlsErrors(@Nullable TlsCertificate certificate, Set<TlsCertificateFlags> errors)
      Emits the "failed-with-tls-errors" signal. See onFailedWithTlsErrors(WebResource.FailedWithTlsErrorsCallback).
    • onFinished

      This signal is emitted when the resource load finishes successfully or due to an error. In case of errors WebKitWebResource::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. See onFinished(WebResource.FinishedCallback).
    • onSentRequest

      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 redirectedResponse 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

      public void emitSentRequest(@Nullable URIRequest request, @Nullable URIResponse redirectedResponse)
      Emits the "sent-request" signal. See onSentRequest(WebResource.SentRequestCallback).
    • builder

      public static WebResource.Builder<? extends WebResource.Builder> builder()
      A WebResource.Builder object constructs a WebResource with the specified properties. Use the various set...() methods to set properties, and finish construction with WebResource.Builder.build().
      Returns:
      the builder object