WebKitWebResource

## WebKitWebResource WebKitWebResource — Represents a resource at the end of a URI |

## Synopsis

    struct              WebKitWebResource;
    const gchar *       webkit_web_resource_get_uri         (WebKitWebResource *resource);
    WebKitURIResponse * webkit_web_resource_get_response    (WebKitWebResource *resource);
    void                webkit_web_resource_get_data        (WebKitWebResource *resource,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);
    guchar *            webkit_web_resource_get_data_finish (WebKitWebResource *resource,
                                                             GAsyncResult *result,
                                                             gsize *length,
                                                             GError **error);

## Object Hierarchy

      GObject
       +----WebKitWebResource

## Properties

      "response"                 WebKitURIResponse*    : Read
      "uri"                      gchar*                : Read

## Signals

      "failed"                                         : Run Last
      "finished"                                       : Run Last
      "received-data"                                  : Run Last
      "sent-request"                                   : Run Last

## Description

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

## Details

### struct WebKitWebResource

    struct WebKitWebResource;

### webkit_web_resource_get_uri ()

    const gchar *       webkit_web_resource_get_uri         (WebKitWebResource *resource);

Returns the current active URI of `resource`. The active URI might change during a load operation:

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

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

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

4. 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`.

`resource` : | a WebKitWebResource
Returns : | the current active URI of `resource`

### webkit_web_resource_get_response ()

    WebKitURIResponse * webkit_web_resource_get_response    (WebKitWebResource *resource);

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.

`resource` : | a WebKitWebResource
Returns : | the WebKitURIResponse, or `NULL` if the response hasn't been received yet. [transfer none]

### webkit_web_resource_get_data ()

    void                webkit_web_resource_get_data        (WebKitWebResource *resource,
                                                             GCancellable *cancellable,
                                                             GAsyncReadyCallback callback,
                                                             gpointer user_data);

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.

`resource` : | a WebKitWebResource
`cancellable` : | a GCancellable or `NULL` to ignore. [allow-none]
`callback` : | a GAsyncReadyCallback to call when the request is satisfied. [scope async]
`user_data` : | the data to pass to callback function. [closure]

### webkit_web_resource_get_data_finish ()

    guchar *            webkit_web_resource_get_data_finish (WebKitWebResource *resource,
                                                             GAsyncResult *result,
                                                             gsize *length,
                                                             GError **error);

Finish an asynchronous operation started with `webkit_web_resource_get_data()`.

`resource` : | a WebKitWebResource
`result` : | a GAsyncResult
`length` : | return location for the length of the resource data. [out]
`error` : | return location for error or `NULL` to ignore
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. [transfer full]

## Property Details

### The `"response"` property

      "response"                 WebKitURIResponse*    : Read

The WebKitURIResponse associated with this resource.

### The `"uri"` property

      "uri"                      gchar*                : Read

The current active URI of the WebKitWebResource. See `webkit_web_resource_get_uri()` for more details.

Default value: NULL

## Signal Details

### The `"failed"` signal

    void                user_function                      (WebKitWebResource *resource,
                                                            gpointer           error,
                                                            gpointer           user_data)      : Run Last

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

`resource` : | the WebKitWebResource
`error` : | the GError that was triggered
`user_data` : | user data set when the signal handler was connected.

### The `"finished"` signal

    void                user_function                      (WebKitWebResource *resource,
                                                            gpointer           user_data)      : Run Last

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

`resource` : | the WebKitWebResource
`user_data` : | user data set when the signal handler was connected.

### The `"received-data"` signal

    void                user_function                      (WebKitWebResource *resource,
                                                            guint64            data_length,
                                                            gpointer           user_data)        : Run Last

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.

`resource` : | the WebKitWebResource
`data_length` : | the length of data received in bytes
`user_data` : | user data set when the signal handler was connected.

### The `"sent-request"` signal

    void                user_function                      (WebKitWebResource *resource,
                                                            WebKitURIRequest  *request,
                                                            WebKitURIResponse *redirected_response,
                                                            gpointer           user_data)                : Run Last

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.

`resource` : | the WebKitWebResource
`request` : | a WebKitURIRequest
`redirected_response` : | a WebKitURIResponse, or `NULL`
`user_data` : | user data set when the signal handler was connected.