28#include <libwapcaplet/libwapcaplet.h>
29#include <nsutils/base64.h>
61 NSLOG(netsurf, INFO,
"fetch_data_initialise called for %s",
62 lwc_string_data(scheme));
69 NSLOG(netsurf, INFO,
"fetch_data_finalise called for %s",
70 lwc_string_data(scheme));
95 len = vsnprintf(header,
sizeof(header), fmt, ap);
98 if (len >= (
int)
sizeof(header) || len < 0) {
109 bool only_2xx,
bool downgrade_tls,
const char *post_urlenc,
111 const char **headers)
159 size_t unescaped_len;
181 if ( (comma = strchr(params,
',')) == NULL) {
188 if (params[0] ==
',') {
190 c->
mimetype = strdup(
"text/plain;charset=US-ASCII");
199 "Unable to allocate memory for mimetype in data: URL";
214 res =
url_unescape(comma + 1, 0, &unescaped_len, &unescaped);
217 msg.
data.
error =
"Unable to URL decode data: URL";
223 if ((nsu_base64_decode_alloc((uint8_t *)unescaped,
225 (uint8_t **)&c->
data,
226 &c->
datalen) != NSUERROR_OK) ||
229 msg.
data.
error =
"Unable to Base64 decode data: URL";
250 while (
ring != NULL) {
270 "setting data: MIME type to %s, length to %"PRIsizet,
294 (
const uint8_t *) c->
data;
304 NSLOG(netsurf, INFO,
"Processing of %.140s failed!",
310 assert(c->
locked ==
false);
326 lwc_string *scheme = lwc_string_ref(corestring_lwc_data);
char * strndup(const char *s, size_t n)
Duplicate up to n characters of a string.
void fetch_set_http_code(struct fetch *fetch, long http_code)
set the http code of a fetch
nserror fetcher_add(lwc_string *scheme, const struct fetcher_operation_table *ops)
Register a fetcher for a scheme.
void fetch_send_callback(const fetch_msg *msg, struct fetch *fetch)
send message to fetch
void fetch_free(struct fetch *f)
Free a fetch structure and associated resources.
void fetch_remove_from_queues(struct fetch *fetch)
remove a queued fetch
Fetching of data from a URL (interface).
Useful interned string pointers (interface).
static void fetch_data_send_header(struct fetch_data_context *ctx, const char *fmt,...)
static bool fetch_data_initialise(lwc_string *scheme)
static void fetch_data_send_callback(const fetch_msg *msg, struct fetch_data_context *c)
static void * fetch_data_setup(struct fetch *parent_fetch, nsurl *url, bool only_2xx, bool downgrade_tls, const char *post_urlenc, const struct fetch_multipart_data *post_multipart, const char **headers)
static bool fetch_data_start(void *ctx)
static void fetch_data_abort(void *ctx)
static void fetch_data_free(void *ctx)
static struct fetch_data_context * ring
static bool fetch_data_can_fetch(const nsurl *url)
static void fetch_data_poll(lwc_string *scheme)
nserror fetch_data_register(void)
Register data scheme handler.
static bool fetch_data_process(struct fetch_data_context *c)
static void fetch_data_finalise(lwc_string *scheme)
data scheme fetch handler interface.
nserror
Enumeration of error codes.
Interface for fetchers factory.
Netsurf additional integer type formatting macros.
#define PRIsizet
c99 standard printf formatting for size_t type
#define NSLOG(catname, level, logmsg, args...)
NetSurf URL handling (interface).
void nsurl_unref(nsurl *url)
Drop a reference to a NetSurf URL object.
const char * nsurl_access(const nsurl *url)
Access a NetSurf URL object as a string.
size_t nsurl_length(const nsurl *url)
Find the length of a NetSurf URL object's URL, as returned by nsurl_access.
nsurl * nsurl_ref(nsurl *url)
Increment the reference count to a NetSurf URL object.
struct nsurl nsurl
NetSurf URL object.
#define RING_REMOVE(ring, element)
Remove the given element from the specified ring.
#define RING_INSERT(ring, element)
Insert the given item into the specified ring.
Interface to utility string handling.
struct fetch_data_context * r_next
struct fetch * parent_fetch
struct fetch_data_context * r_prev
struct fetch_msg::@118::@119 header_or_data
union fetch_msg::@118 data
Fetch POST multipart data.
Information for a single fetch.
bool(* initialise)(lwc_string *scheme)
The initialiser for the fetcher.
nserror url_unescape(const char *str, size_t length, size_t *length_out, char **result_out)
Convert an escaped string to plain.
Interface to URL parsing and joining operations.
Interface to a number of general purpose functionality.
#define SLEN(x)
Calculate length of constant C string.