NetSurf
|
resource scheme URL handling. More...
#include <stdlib.h>
#include <stdbool.h>
#include <string.h>
#include <strings.h>
#include <stdio.h>
#include <stdarg.h>
#include <libwapcaplet/libwapcaplet.h>
#include "netsurf/inttypes.h"
#include "utils/nsurl.h"
#include "utils/corestrings.h"
#include "utils/log.h"
#include "utils/time.h"
#include "utils/messages.h"
#include "utils/utils.h"
#include "utils/ring.h"
#include "netsurf/fetch.h"
#include "desktop/gui_internal.h"
#include "content/fetch.h"
#include "content/fetchers.h"
#include "content/fetchers/resource.h"
Go to the source code of this file.
Data Structures | |
struct | fetch_resource_map_entry |
map of resource scheme paths to redirect urls More... | |
struct | fetch_resource_context |
Context for an resource fetch. More... | |
Macros | |
#define | DIRECT_ETAG_VALUE 123456 |
Typedefs | |
typedef bool(* | fetch_resource_handler) (struct fetch_resource_context *) |
Functions | |
static bool | fetch_resource_send_callback (const fetch_msg *msg, struct fetch_resource_context *ctx) |
issue fetch callbacks with locking More... | |
static bool | fetch_resource_send_header (struct fetch_resource_context *ctx, const char *fmt,...) |
static bool | fetch_resource_redirect_handler (struct fetch_resource_context *ctx) |
resource handler that results in a redirect to another url. More... | |
static bool | fetch_resource_data_handler (struct fetch_resource_context *ctx) |
static bool | fetch_resource_notfound_handler (struct fetch_resource_context *ctx) |
static bool | fetch_resource_initialise (lwc_string *scheme) |
callback to initialise the resource fetcher. More... | |
static void | fetch_resource_finalise (lwc_string *scheme) |
callback to finalise the resource fetcher. More... | |
static bool | fetch_resource_can_fetch (const nsurl *url) |
static void * | fetch_resource_setup (struct fetch *fetchh, nsurl *url, bool only_2xx, bool downgrade_tls, const char *post_urlenc, const struct fetch_multipart_data *post_multipart, const char **headers) |
set up a resource fetch context. More... | |
static void | fetch_resource_free (void *ctx) |
callback to free a resource fetch More... | |
static bool | fetch_resource_start (void *ctx) |
callback to start a resource fetch More... | |
static void | fetch_resource_abort (void *ctx) |
callback to abort a resource fetch More... | |
static void | fetch_resource_poll (lwc_string *scheme) |
callback to poll for additional resource fetch contents More... | |
nserror | fetch_resource_register (void) |
Register the resource scheme. More... | |
Variables | |
static const char * | fetch_resource_paths [] |
Valid resource paths. More... | |
static struct fetch_resource_map_entry | fetch_resource_map [NOF_ELEMENTS(fetch_resource_paths)] |
static struct fetch_resource_context * | ring = NULL |
static uint32_t | fetch_resource_path_count |
resource scheme URL handling.
Based on the data fetcher by Rob Kendrick
Definition in file resource.c.
#define DIRECT_ETAG_VALUE 123456 |
Definition at line 47 of file resource.c.
typedef bool(* fetch_resource_handler) (struct fetch_resource_context *) |
Definition at line 83 of file resource.c.
|
static |
callback to abort a resource fetch
Definition at line 429 of file resource.c.
References fetch_resource_context::aborted.
Referenced by fetch_resource_register().
|
static |
Definition at line 329 of file resource.c.
Referenced by fetch_resource_register().
|
static |
Definition at line 161 of file resource.c.
References fetch_resource_context::aborted, fetch_msg::buf, fetch_msg::data, fetch_resource_map_entry::data, fetch_resource_map_entry::data_len, DIRECT_ETAG_VALUE, fetch_resource_context::entry, fetch_resource_context::etag, netsurf_table::fetch, FETCH_DATA, FETCH_FINISHED, FETCH_NOTMODIFIED, fetch_resource_send_callback(), fetch_resource_send_header(), fetch_set_http_code(), fetch_resource_context::fetchh, gui_fetch_table::filetype, guit, fetch_msg::header_or_data, fetch_msg::len, fetch_resource_map_entry::path, PRId64, PRIsizet, and fetch_msg::type.
Referenced by fetch_resource_setup().
|
static |
callback to finalise the resource fetcher.
Definition at line 315 of file resource.c.
References fetch_resource_map_entry::data, netsurf_table::fetch, fetch_resource_map, fetch_resource_path_count, guit, nsurl_unref(), path(), fetch_resource_map_entry::redirect_url, and gui_fetch_table::release_resource_data.
Referenced by fetch_resource_register().
|
static |
callback to free a resource fetch
Definition at line 414 of file resource.c.
References nsurl_unref(), and fetch_resource_context::url.
Referenced by fetch_resource_register().
|
static |
callback to initialise the resource fetcher.
Definition at line 269 of file resource.c.
References fetch_resource_map_entry::data, fetch_resource_map_entry::data_len, netsurf_table::fetch, fetch_resource_map, fetch_resource_path_count, fetch_resource_paths, gui_fetch_table::get_resource_data, gui_fetch_table::get_resource_url, guit, NOF_ELEMENTS, NSERROR_OK, NSLOG, nsurl_unref(), fetch_resource_map_entry::path, path(), and fetch_resource_map_entry::redirect_url.
Referenced by fetch_resource_register().
|
static |
Definition at line 220 of file resource.c.
References fetch_msg::buf, buffer, fetch_msg::data, FETCH_DATA, FETCH_FINISHED, fetch_resource_send_callback(), fetch_resource_send_header(), fetch_set_http_code(), fetch_resource_context::fetchh, fetch_msg::header_or_data, fetch_msg::len, messages_get(), nsurl_access(), fetch_msg::type, and fetch_resource_context::url.
Referenced by fetch_resource_setup().
|
static |
callback to poll for additional resource fetch contents
Definition at line 442 of file resource.c.
References fetch_resource_context::aborted, fetch_free(), fetch_remove_from_queues(), fetch_resource_context::fetchh, fetch_resource_context::handler, fetch_resource_context::locked, ring, RING_INSERT, and RING_REMOVE.
Referenced by fetch_resource_register().
|
static |
resource handler that results in a redirect to another url.
Definition at line 146 of file resource.c.
References fetch_msg::data, fetch_resource_context::entry, FETCH_REDIRECT, fetch_resource_send_callback(), fetch_set_http_code(), fetch_resource_context::fetchh, nsurl_access(), fetch_msg::redirect, fetch_resource_map_entry::redirect_url, and fetch_msg::type.
Referenced by fetch_resource_setup().
nserror fetch_resource_register | ( | void | ) |
Register the resource scheme.
should only be called from the fetch initialise
Definition at line 479 of file resource.c.
References fetch_resource_abort(), fetch_resource_can_fetch(), fetch_resource_finalise(), fetch_resource_free(), fetch_resource_initialise(), fetch_resource_poll(), fetch_resource_setup(), fetch_resource_start(), fetcher_add(), and fetcher_operation_table::initialise.
Referenced by fetcher_init().
|
inlinestatic |
issue fetch callbacks with locking
Definition at line 108 of file resource.c.
References fetch_resource_context::aborted, fetch_send_callback(), fetch_resource_context::fetchh, and fetch_resource_context::locked.
Referenced by fetch_resource_data_handler(), fetch_resource_notfound_handler(), fetch_resource_redirect_handler(), and fetch_resource_send_header().
|
static |
Definition at line 118 of file resource.c.
References fetch_msg::buf, fetch_msg::data, FETCH_HEADER, fetch_resource_send_callback(), fetch_msg::header_or_data, fetch_msg::len, and fetch_msg::type.
Referenced by fetch_resource_data_handler(), and fetch_resource_notfound_handler().
|
static |
set up a resource fetch context.
Definition at line 338 of file resource.c.
References fetch_resource_map_entry::data, fetch_resource_context::entry, fetch_resource_context::etag, fetch_resource_data_handler(), fetch_resource_map, fetch_resource_notfound_handler(), fetch_resource_path_count, fetch_resource_redirect_handler(), fetch_resource_context::fetchh, fetch_resource_context::handler, nsc_snptimet(), NSERROR_OK, NSLOG, nsurl_get_component(), NSURL_PATH, nsurl_ref(), path(), ring, RING_INSERT, SLEN, and fetch_resource_context::url.
Referenced by fetch_resource_register().
|
static |
callback to start a resource fetch
Definition at line 423 of file resource.c.
Referenced by fetch_resource_register().
|
static |
Referenced by fetch_resource_finalise(), fetch_resource_initialise(), and fetch_resource_setup().
|
static |
Definition at line 105 of file resource.c.
Referenced by fetch_resource_finalise(), fetch_resource_initialise(), and fetch_resource_setup().
|
static |
Valid resource paths.
Definition at line 50 of file resource.c.
Referenced by fetch_resource_initialise().
|
static |
Definition at line 103 of file resource.c.
Referenced by fetch_resource_poll(), and fetch_resource_setup().