r9634 jmb - in /branches/jmb/new-cache: amiga/ beos/ content/ content/fetchers/ desktop/ render/
by netsurf@semichrome.net
Author: jmb
Date: Wed Oct 14 19:15:10 2009
New Revision: 9634
URL: http://source.netsurf-browser.org?rev=9634&view=rev
Log:
Replace form_successful_control with fetch_multipart_data
Modified:
branches/jmb/new-cache/amiga/fetch_file.c
branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp
branches/jmb/new-cache/content/fetch.c
branches/jmb/new-cache/content/fetch.h
branches/jmb/new-cache/content/fetchcache.c
branches/jmb/new-cache/content/fetchcache.h
branches/jmb/new-cache/content/fetchers/fetch_curl.c
branches/jmb/new-cache/content/fetchers/fetch_data.c
branches/jmb/new-cache/content/llcache.c
branches/jmb/new-cache/content/llcache.h
branches/jmb/new-cache/desktop/browser.c
branches/jmb/new-cache/desktop/browser.h
branches/jmb/new-cache/render/form.c
branches/jmb/new-cache/render/form.h
branches/jmb/new-cache/render/html.c
branches/jmb/new-cache/render/html.h
Modified: branches/jmb/new-cache/amiga/fetch_file.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/amiga/fetch_file...
==============================================================================
--- branches/jmb/new-cache/amiga/fetch_file.c (original)
+++ branches/jmb/new-cache/amiga/fetch_file.c Wed Oct 14 19:15:10 2009
@@ -56,7 +56,7 @@
static void ami_fetch_file_finalise(const char *scheme);
static void * ami_fetch_file_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers);
static bool ami_fetch_file_start(void *vfetch);
static void ami_fetch_file_abort(void *vf);
@@ -135,7 +135,7 @@
void * ami_fetch_file_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
struct ami_file_fetch_info *fetch;
Modified: branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/beos/beos_fetch_...
==============================================================================
--- branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp (original)
+++ branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp Wed Oct 14 19:15:10 2009
@@ -83,7 +83,7 @@
static void *fetch_rsrc_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
struct fetch_rsrc_context *ctx;
Modified: branches/jmb/new-cache/content/fetch.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetch.c?...
==============================================================================
--- branches/jmb/new-cache/content/fetch.c (original)
+++ branches/jmb/new-cache/content/fetch.c Wed Oct 14 19:15:10 2009
@@ -214,7 +214,7 @@
struct fetch * fetch_start(const char *url, const char *referer,
fetch_callback callback,
void *p, bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent,
char *headers[])
{
@@ -599,6 +599,78 @@
return fetch->verifiable;
}
+/**
+ * Clone a linked list of fetch_multipart_data.
+ *
+ * \param list List to clone
+ * \return Pointer to head of cloned list, or NULL on failure
+ */
+struct fetch_multipart_data *fetch_multipart_data_clone(
+ const struct fetch_multipart_data *list)
+{
+ struct fetch_multipart_data *clone, *last = NULL;
+ struct fetch_multipart_data *result = NULL;
+
+ for (; list != NULL; list = list->next) {
+ clone = malloc(sizeof(struct fetch_multipart_data));
+ if (clone == NULL) {
+ if (result != NULL)
+ fetch_multipart_data_destroy(result);
+
+ return NULL;
+ }
+
+ clone->file = list->file;
+
+ clone->name = strdup(list->name);
+ if (clone->name == NULL) {
+ free(clone);
+ if (result != NULL)
+ fetch_multipart_data_destroy(result);
+
+ return NULL;
+ }
+
+ clone->value = strdup(list->value);
+ if (clone->value == NULL) {
+ free(clone->name);
+ free(clone);
+ if (result != NULL)
+ fetch_multipart_data_destroy(result);
+
+ return NULL;
+ }
+
+ clone->next = NULL;
+
+ if (result == NULL)
+ result = clone;
+ else
+ last->next = clone;
+
+ last = clone;
+ }
+
+ return result;
+}
+
+/**
+ * Free a linked list of fetch_multipart_data.
+ *
+ * \param list Pointer to head of list to free
+ */
+void fetch_multipart_data_destroy(struct fetch_multipart_data *list)
+{
+ struct fetch_multipart_data *next;
+
+ for (; list != NULL; list = next) {
+ next = list->next;
+ free(list->name);
+ free(list->value);
+ free(list);
+ }
+}
+
void
fetch_send_callback(fetch_msg msg, struct fetch *fetch, const void *data,
unsigned long size)
Modified: branches/jmb/new-cache/content/fetch.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetch.h?...
==============================================================================
--- branches/jmb/new-cache/content/fetch.h (original)
+++ branches/jmb/new-cache/content/fetch.h Wed Oct 14 19:15:10 2009
@@ -42,7 +42,15 @@
struct content;
struct fetch;
-struct form_successful_control;
+
+/** Fetch POST multipart data */
+struct fetch_multipart_data {
+ bool file; /**< Item is a file */
+ char *name; /**< Name of item */
+ char *value; /**< Item value */
+
+ struct fetch_multipart_data *next; /**< Next in linked list */
+};
struct ssl_cert_info {
long version; /**< Certificate version */
@@ -65,7 +73,7 @@
struct fetch * fetch_start(const char *url, const char *referer,
fetch_callback callback,
void *p, bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent,
char *headers[]);
void fetch_abort(struct fetch *f);
@@ -82,12 +90,16 @@
struct content *fetch_get_parent(struct fetch *fetch);
bool fetch_get_verifiable(struct fetch *fetch);
+void fetch_multipart_data_destroy(struct fetch_multipart_data *list);
+struct fetch_multipart_data *fetch_multipart_data_clone(
+ const struct fetch_multipart_data *list);
+
/* API for fetchers themselves */
typedef bool (*fetcher_initialise)(const char *);
typedef void* (*fetcher_setup_fetch)(struct fetch *, const char *,
bool, const char *,
- struct form_successful_control *,
+ struct fetch_multipart_data *,
const char **);
typedef bool (*fetcher_start_fetch)(void *);
typedef void (*fetcher_abort_fetch)(void *);
Modified: branches/jmb/new-cache/content/fetchcache.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchcac...
==============================================================================
--- branches/jmb/new-cache/content/fetchcache.c (original)
+++ branches/jmb/new-cache/content/fetchcache.c Wed Oct 14 19:15:10 2009
@@ -94,7 +94,7 @@
int width, int height,
bool no_error_pages,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable,
bool download)
{
@@ -242,7 +242,7 @@
intptr_t p1, intptr_t p2,
int width, int height,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent)
{
char error_message[500];
Modified: branches/jmb/new-cache/content/fetchcache.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchcac...
==============================================================================
--- branches/jmb/new-cache/content/fetchcache.h (original)
+++ branches/jmb/new-cache/content/fetchcache.h Wed Oct 14 19:15:10 2009
@@ -30,7 +30,7 @@
#include <stdint.h>
#include "content/content.h"
-struct form_successful_control;
+struct fetch_multipart_data;
void fetchcache_init(void);
struct content * fetchcache(const char *url,
@@ -40,7 +40,7 @@
int width, int height,
bool no_error_pages,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable,
bool download);
void fetchcache_go(struct content *content, const char *referer,
@@ -49,7 +49,7 @@
intptr_t p1, intptr_t p2,
int width, int height,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool verifiable, struct content *parent);
#endif
Modified: branches/jmb/new-cache/content/fetchers/fetch_curl.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchers...
==============================================================================
--- branches/jmb/new-cache/content/fetchers/fetch_curl.c (original)
+++ branches/jmb/new-cache/content/fetchers/fetch_curl.c Wed Oct 14 19:15:10 2009
@@ -105,7 +105,7 @@
static void fetch_curl_finalise(const char *scheme);
static void * fetch_curl_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers);
static bool fetch_curl_start(void *vfetch);
static bool fetch_curl_initiate_fetch(struct curl_fetch_info *fetch,
@@ -133,7 +133,7 @@
void *_f);
static bool fetch_curl_process_headers(struct curl_fetch_info *f);
static struct curl_httppost *fetch_curl_post_convert(
- struct form_successful_control *control);
+ struct fetch_multipart_data *control);
static int fetch_curl_verify_callback(int preverify_ok,
X509_STORE_CTX *x509_ctx);
static int fetch_curl_cert_verify_callback(X509_STORE_CTX *x509_ctx,
@@ -295,7 +295,7 @@
void * fetch_curl_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
char *host;
@@ -1183,11 +1183,11 @@
/**
- * Convert a list of struct ::form_successful_control to a list of
+ * Convert a list of struct ::fetch_multipart_data to a list of
* struct curl_httppost for libcurl.
*/
struct curl_httppost *
-fetch_curl_post_convert(struct form_successful_control *control)
+fetch_curl_post_convert(struct fetch_multipart_data *control)
{
struct curl_httppost *post = 0, *last = 0;
CURLFORMcode code;
Modified: branches/jmb/new-cache/content/fetchers/fetch_data.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchers...
==============================================================================
--- branches/jmb/new-cache/content/fetchers/fetch_data.c (original)
+++ branches/jmb/new-cache/content/fetchers/fetch_data.c Wed Oct 14 19:15:10 2009
@@ -79,7 +79,7 @@
static void *fetch_data_setup(struct fetch *parent_fetch, const char *url,
bool only_2xx, const char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
const char **headers)
{
struct fetch_data_context *ctx = calloc(1, sizeof(*ctx));
Modified: branches/jmb/new-cache/content/llcache.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.c (original)
+++ branches/jmb/new-cache/content/llcache.c Wed Oct 14 19:15:10 2009
@@ -686,7 +686,7 @@
nserror llcache_object_refetch(llcache_object *object)
{
const char *urlenc = NULL;
- struct form_successful_control *multipart = NULL;
+ struct fetch_multipart_data *multipart = NULL;
if (object->fetch.post != NULL) {
if (object->fetch.post->type == LLCACHE_POST_URL_ENCODED)
@@ -760,7 +760,7 @@
if (object->fetch.post->type == LLCACHE_POST_URL_ENCODED) {
free(object->fetch.post->data.urlenc);
} else {
- form_free_successful(
+ fetch_multipart_data_destroy(
object->fetch.post->data.multipart);
}
@@ -1036,8 +1036,8 @@
return NSERROR_NOMEM;
}
} else {
- post_clone->data.multipart =
- form_clone_successful(orig->data.multipart);
+ post_clone->data.multipart = fetch_multipart_data_clone(
+ orig->data.multipart);
if (post_clone->data.multipart == NULL) {
free(post_clone);
Modified: branches/jmb/new-cache/content/llcache.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.h (original)
+++ branches/jmb/new-cache/content/llcache.h Wed Oct 14 19:15:10 2009
@@ -30,7 +30,7 @@
#include "utils/errors.h"
struct ssl_cert_info;
-struct form_successful_control;
+struct fetch_multipart_data;
/** Type of low-level cache object */
typedef struct llcache_object llcache_object;
@@ -46,8 +46,7 @@
} type; /**< Type of POST data */
union {
char *urlenc; /**< URL encoded data */
- /** \todo Need to abstract this away from HTML forms. */
- struct form_successful_control *multipart; /**< Multipart data */
+ struct fetch_multipart_data *multipart; /**< Multipart data */
} data; /**< POST data content */
} llcache_post_data;
Modified: branches/jmb/new-cache/desktop/browser.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/desktop/browser....
==============================================================================
--- branches/jmb/new-cache/desktop/browser.c (original)
+++ branches/jmb/new-cache/desktop/browser.c Wed Oct 14 19:15:10 2009
@@ -77,7 +77,7 @@
static void browser_window_go_post(struct browser_window *bw,
const char *url, char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool add_to_history, const char *referer, bool download,
bool verifiable, struct content *parent);
static void browser_window_callback(content_msg msg, struct content *c,
@@ -276,7 +276,7 @@
void browser_window_go_post(struct browser_window *bw, const char *url,
char *post_urlenc,
- struct form_successful_control *post_multipart,
+ struct fetch_multipart_data *post_multipart,
bool add_to_history, const char *referer, bool download,
bool verifiable, struct content *parent)
{
@@ -2479,11 +2479,12 @@
* Collect controls and submit a form.
*/
-void browser_form_submit(struct browser_window *bw, struct browser_window *target,
+void browser_form_submit(struct browser_window *bw,
+ struct browser_window *target,
struct form *form, struct form_control *submit_button)
{
char *data = 0, *url = 0;
- struct form_successful_control *success;
+ struct fetch_multipart_data *success;
assert(form);
assert(bw->current_content->type == CONTENT_HTML);
@@ -2497,14 +2498,14 @@
case method_GET:
data = form_url_encode(form, success);
if (!data) {
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
warn_user("NoMemory", 0);
return;
}
url = calloc(1, strlen(form->action) +
strlen(data) + 2);
if (!url) {
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
free(data);
warn_user("NoMemory", 0);
return;
@@ -2522,7 +2523,7 @@
case method_POST_URLENC:
data = form_url_encode(form, success);
if (!data) {
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
warn_user("NoMemory", 0);
return;
}
@@ -2542,7 +2543,7 @@
assert(0);
}
- form_free_successful(success);
+ fetch_multipart_data_destroy(success);
free(data);
free(url);
}
Modified: branches/jmb/new-cache/desktop/browser.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/desktop/browser....
==============================================================================
--- branches/jmb/new-cache/desktop/browser.h (original)
+++ branches/jmb/new-cache/desktop/browser.h Wed Oct 14 19:15:10 2009
@@ -34,7 +34,6 @@
struct content;
struct form;
struct form_control;
-struct form_successful_control;
struct gui_window;
struct history;
struct selection;
Modified: branches/jmb/new-cache/render/form.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/form.c?re...
==============================================================================
--- branches/jmb/new-cache/render/form.c (original)
+++ branches/jmb/new-cache/render/form.c Wed Oct 14 19:15:10 2009
@@ -30,6 +30,7 @@
#include <stdbool.h>
#include <stdio.h>
#include <string.h>
+#include "content/fetch.h"
#include "css/css.h"
#include "css/utils.h"
#include "desktop/gui.h"
@@ -308,18 +309,18 @@
* \param form form to search for successful controls
* \param submit_button control used to submit the form, if any
* \param successful_controls updated to point to linked list of
- * form_successful_control, 0 if no controls
+ * fetch_multipart_data, 0 if no controls
* \return true on success, false on memory exhaustion
*
* See HTML 4.01 section 17.13.2.
*/
bool form_successful_controls(struct form *form,
struct form_control *submit_button,
- struct form_successful_control **successful_controls)
+ struct fetch_multipart_data **successful_controls)
{
struct form_control *control;
struct form_option *option;
- struct form_successful_control sentinel, *last_success, *success_new;
+ struct fetch_multipart_data sentinel, *last_success, *success_new;
char *value = NULL;
bool had_submit = false;
char *charset;
@@ -603,7 +604,7 @@
no_memory:
warn_user("NoMemory", 0);
- form_free_successful(sentinel.next);
+ fetch_multipart_data_destroy(sentinel.next);
return false;
#undef ENCODE_ITEM
@@ -659,12 +660,12 @@
* Encode controls using application/x-www-form-urlencoded.
*
* \param form form to which successful controls relate
- * \param control linked list of form_successful_control
+ * \param control linked list of fetch_multipart_data
* \return URL-encoded form, or 0 on memory exhaustion
*/
char *form_url_encode(struct form *form,
- struct form_successful_control *control)
+ struct fetch_multipart_data *control)
{
char *name, *value;
char *s = malloc(1), *s2;
@@ -711,78 +712,6 @@
if (len)
s[len - 1] = 0;
return s;
-}
-
-/**
- * Clone a linked list of form_successful control.
- *
- * \param list List to clone
- * \return Pointer to head of cloned list, or NULL on failure
- */
-struct form_successful_control *form_clone_successful(
- const struct form_successful_control *list)
-{
- struct form_successful_control *clone, *last = NULL;
- struct form_successful_control *result = NULL;
-
- for (; list != NULL; list = list->next) {
- clone = malloc(sizeof(struct form_successful_control));
- if (clone == NULL) {
- if (result != NULL)
- form_free_successful(result);
-
- return NULL;
- }
-
- clone->file = list->file;
-
- clone->name = strdup(list->name);
- if (clone->name == NULL) {
- free(clone);
- if (result != NULL)
- form_free_successful(result);
-
- return NULL;
- }
-
- clone->value = strdup(list->value);
- if (clone->value == NULL) {
- free(clone->name);
- free(clone);
- if (result != NULL)
- form_free_successful(result);
-
- return NULL;
- }
-
- clone->next = NULL;
-
- if (result == NULL)
- result = clone;
- else
- last->next = clone;
-
- last = clone;
- }
-
- return result;
-}
-
-/**
- * Free a linked list of form_successful_control.
- *
- * \param control Pointer to head of list to free
- */
-
-void form_free_successful(struct form_successful_control *control)
-{
- struct form_successful_control *next;
- for (; control; control = next) {
- next = control->next;
- free(control->name);
- free(control->value);
- free(control);
- }
}
/**
Modified: branches/jmb/new-cache/render/form.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/form.h?re...
==============================================================================
--- branches/jmb/new-cache/render/form.h (original)
+++ branches/jmb/new-cache/render/form.h Wed Oct 14 19:15:10 2009
@@ -125,14 +125,6 @@
struct form_option* next;
};
-/** Successful control, as defined by HTML 4.01 17.13. */
-struct form_successful_control {
- bool file; /**< It's a file */
- char *name; /**< Control name. */
- char *value; /**< Current value. */
- struct form_successful_control *next; /**< Next in linked list. */
-};
-
/**
* Called by the select menu when it wants an area to be redrawn. The
* coordinates are menu origin relative.
@@ -157,12 +149,9 @@
bool selected);
bool form_successful_controls(struct form *form,
struct form_control *submit_button,
- struct form_successful_control **successful_controls);
+ struct fetch_multipart_data **successful_controls);
char *form_url_encode(struct form *form,
- struct form_successful_control *control);
-struct form_successful_control *form_clone_successful(
- const struct form_successful_control *list);
-void form_free_successful(struct form_successful_control *control);
+ struct fetch_multipart_data *control);
bool form_open_select_menu(void *client_data,
struct form_control *control,
Modified: branches/jmb/new-cache/render/html.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/html.c?re...
==============================================================================
--- branches/jmb/new-cache/render/html.c (original)
+++ branches/jmb/new-cache/render/html.c Wed Oct 14 19:15:10 2009
@@ -1316,7 +1316,7 @@
bool html_replace_object(struct content *c, unsigned int i, char *url,
char *post_urlenc,
- struct form_successful_control *post_multipart)
+ struct fetch_multipart_data *post_multipart)
{
struct content *c_fetch;
struct content *page;
Modified: branches/jmb/new-cache/render/html.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/html.h?re...
==============================================================================
--- branches/jmb/new-cache/render/html.h (original)
+++ branches/jmb/new-cache/render/html.h Wed Oct 14 19:15:10 2009
@@ -31,11 +31,11 @@
#include "desktop/plot_style.h"
#include "render/parser_binding.h"
+struct fetch_multipart_data;
struct box;
struct rect;
struct browser_window;
struct content;
-struct form_successful_control;
struct imagemap;
struct object_params;
struct plotters;
@@ -183,7 +183,7 @@
bool background);
bool html_replace_object(struct content *c, unsigned int i, char *url,
char *post_urlenc,
- struct form_successful_control *post_multipart);
+ struct fetch_multipart_data *post_multipart);
void html_stop(struct content *c);
void html_open(struct content *c, struct browser_window *bw,
struct content *page, unsigned int index, struct box *box,
13 years, 7 months
r9633 jmb - in /branches/jmb/new-cache: content/llcache.c content/llcache.h render/form.c render/form.h
by netsurf@semichrome.net
Author: jmb
Date: Wed Oct 14 10:14:30 2009
New Revision: 9633
URL: http://source.netsurf-browser.org?rev=9633&view=rev
Log:
Clone POST data
Modified:
branches/jmb/new-cache/content/llcache.c
branches/jmb/new-cache/content/llcache.h
branches/jmb/new-cache/render/form.c
branches/jmb/new-cache/render/form.h
Modified: branches/jmb/new-cache/content/llcache.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.c (original)
+++ branches/jmb/new-cache/content/llcache.c Wed Oct 14 10:14:30 2009
@@ -29,6 +29,7 @@
#include "content/fetch.h"
#include "content/llcache.h"
+#include "render/form.h"
#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utils.h"
@@ -162,6 +163,9 @@
static nserror llcache_object_notify_users(llcache_object *object);
static nserror llcache_clean(void);
+
+static nserror llcache_post_data_clone(const llcache_post_data *orig,
+ llcache_post_data **clone);
static nserror llcache_query_handle_response(bool proceed, void *cbpw);
@@ -650,6 +654,7 @@
nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
const char *referer, const llcache_post_data *post)
{
+ nserror error;
char *referer_clone;
llcache_post_data *post_clone;
@@ -657,8 +662,11 @@
if (referer_clone == NULL)
return NSERROR_NOMEM;
- /** \todo clone post */
- post_clone = (llcache_post_data *) post;
+ error = llcache_post_data_clone(post, &post_clone);
+ if (error != NSERROR_OK) {
+ free(referer_clone);
+ return error;
+ }
object->fetch.flags = flags;
object->fetch.referer = referer_clone;
@@ -747,7 +755,17 @@
}
free(object->fetch.referer);
- /** \todo Destroy POST data */
+
+ if (object->fetch.post != NULL) {
+ if (object->fetch.post->type == LLCACHE_POST_URL_ENCODED) {
+ free(object->fetch.post->data.urlenc);
+ } else {
+ form_free_successful(
+ object->fetch.post->data.multipart);
+ }
+
+ free(object->fetch.post);
+ }
free(object->cache.etag);
@@ -992,6 +1010,47 @@
}
/**
+ * Clone a POST data object
+ *
+ * \param orig Object to clone
+ * \param clone Pointer to location to receive clone
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror llcache_post_data_clone(const llcache_post_data *orig,
+ llcache_post_data **clone)
+{
+ llcache_post_data *post_clone;
+
+ post_clone = calloc(1, sizeof(llcache_post_data));
+ if (post_clone == NULL)
+ return NSERROR_NOMEM;
+
+ post_clone->type = orig->type;
+
+ /* Deep-copy the type-specific data */
+ if (orig->type == LLCACHE_POST_URL_ENCODED) {
+ post_clone->data.urlenc = strdup(orig->data.urlenc);
+ if (post_clone->data.urlenc == NULL) {
+ free(post_clone);
+
+ return NSERROR_NOMEM;
+ }
+ } else {
+ post_clone->data.multipart =
+ form_clone_successful(orig->data.multipart);
+ if (post_clone->data.multipart == NULL) {
+ free(post_clone);
+
+ return NSERROR_NOMEM;
+ }
+ }
+
+ *clone = post_clone;
+
+ return NSERROR_OK;
+}
+
+/**
* Handle a query response
*
* \param proceed Whether to proceed with fetch
Modified: branches/jmb/new-cache/content/llcache.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.h (original)
+++ branches/jmb/new-cache/content/llcache.h Wed Oct 14 10:14:30 2009
@@ -45,7 +45,7 @@
LLCACHE_POST_MULTIPART
} type; /**< Type of POST data */
union {
- const char *urlenc; /**< URL encoded data */
+ char *urlenc; /**< URL encoded data */
/** \todo Need to abstract this away from HTML forms. */
struct form_successful_control *multipart; /**< Multipart data */
} data; /**< POST data content */
Modified: branches/jmb/new-cache/render/form.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/form.c?re...
==============================================================================
--- branches/jmb/new-cache/render/form.c (original)
+++ branches/jmb/new-cache/render/form.c Wed Oct 14 10:14:30 2009
@@ -713,6 +713,60 @@
return s;
}
+/**
+ * Clone a linked list of form_successful control.
+ *
+ * \param list List to clone
+ * \return Pointer to head of cloned list, or NULL on failure
+ */
+struct form_successful_control *form_clone_successful(
+ const struct form_successful_control *list)
+{
+ struct form_successful_control *clone, *last = NULL;
+ struct form_successful_control *result = NULL;
+
+ for (; list != NULL; list = list->next) {
+ clone = malloc(sizeof(struct form_successful_control));
+ if (clone == NULL) {
+ if (result != NULL)
+ form_free_successful(result);
+
+ return NULL;
+ }
+
+ clone->file = list->file;
+
+ clone->name = strdup(list->name);
+ if (clone->name == NULL) {
+ free(clone);
+ if (result != NULL)
+ form_free_successful(result);
+
+ return NULL;
+ }
+
+ clone->value = strdup(list->value);
+ if (clone->value == NULL) {
+ free(clone->name);
+ free(clone);
+ if (result != NULL)
+ form_free_successful(result);
+
+ return NULL;
+ }
+
+ clone->next = NULL;
+
+ if (result == NULL)
+ result = clone;
+ else
+ last->next = clone;
+
+ last = clone;
+ }
+
+ return result;
+}
/**
* Free a linked list of form_successful_control.
Modified: branches/jmb/new-cache/render/form.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/render/form.h?re...
==============================================================================
--- branches/jmb/new-cache/render/form.h (original)
+++ branches/jmb/new-cache/render/form.h Wed Oct 14 10:14:30 2009
@@ -160,6 +160,8 @@
struct form_successful_control **successful_controls);
char *form_url_encode(struct form *form,
struct form_successful_control *control);
+struct form_successful_control *form_clone_successful(
+ const struct form_successful_control *list);
void form_free_successful(struct form_successful_control *control);
bool form_open_select_menu(void *client_data,
13 years, 7 months
r9632 jmb - /branches/jmb/new-cache/content/llcache.c
by netsurf@semichrome.net
Author: jmb
Date: Wed Oct 14 09:23:14 2009
New Revision: 9632
URL: http://source.netsurf-browser.org?rev=9632&view=rev
Log:
Purge some redundant todos
Modified:
branches/jmb/new-cache/content/llcache.c
Modified: branches/jmb/new-cache/content/llcache.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.c (original)
+++ branches/jmb/new-cache/content/llcache.c Wed Oct 14 09:23:14 2009
@@ -881,8 +881,6 @@
* DONE : on transition from DATA -> COMPLETE state
*/
- /** \todo How are we going to handle errors here? */
-
for (user = object->users; user != NULL; user = user->next) {
/* Emit necessary events to bring the user up-to-date */
llcache_handle *handle = &user->handle;
@@ -1166,7 +1164,6 @@
/* Make target absolute */
result = url_join(target, object->url, &absurl);
if (result != URL_FUNC_OK) {
- /** \todo handle error */
return NSERROR_NOMEM;
}
@@ -1177,7 +1174,6 @@
free(absurl);
if (result != URL_FUNC_OK) {
- /** \todo handle error */
return NSERROR_NOMEM;
}
13 years, 7 months
r9631 jmb - in /branches/jmb/new-cache/content: llcache.c llcache.h
by netsurf@semichrome.net
Author: jmb
Date: Mon Oct 12 21:36:48 2009
New Revision: 9631
URL: http://source.netsurf-browser.org?rev=9631&view=rev
Log:
Handlers for the remaining FETCH_ states.
Modified:
branches/jmb/new-cache/content/llcache.c
branches/jmb/new-cache/content/llcache.h
Modified: branches/jmb/new-cache/content/llcache.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.c (original)
+++ branches/jmb/new-cache/content/llcache.c Mon Oct 12 21:36:48 2009
@@ -29,6 +29,7 @@
#include "content/fetch.h"
#include "content/llcache.h"
+#include "utils/messages.h"
#include "utils/url.h"
#include "utils/utils.h"
@@ -144,6 +145,7 @@
llcache_object *destination, bool deep);
static nserror llcache_object_fetch(llcache_object *object, uint32_t flags,
const char *referer, const llcache_post_data *post);
+static nserror llcache_object_refetch(llcache_object *object);
static nserror llcache_object_new(const char *url, llcache_object **result);
static nserror llcache_object_destroy(llcache_object *object);
@@ -160,6 +162,8 @@
static nserror llcache_object_notify_users(llcache_object *object);
static nserror llcache_clean(void);
+
+static nserror llcache_query_handle_response(bool proceed, void *cbpw);
static void llcache_fetch_callback(fetch_msg msg, void *p, const void *data,
unsigned long size);
@@ -175,6 +179,10 @@
const char *data, size_t len);
static nserror llcache_fetch_process_data(llcache_object *object,
const uint8_t *data, size_t len);
+static nserror llcache_fetch_auth(llcache_object *object,
+ const char *realm);
+static nserror llcache_fetch_cert_error(llcache_object *object,
+ const struct ssl_cert_info *certs, size_t num);
/******************************************************************************
@@ -644,8 +652,6 @@
{
char *referer_clone;
llcache_post_data *post_clone;
- const char *urlenc = NULL;
- struct form_successful_control *multipart = NULL;
referer_clone = strdup(referer);
if (referer_clone == NULL)
@@ -657,6 +663,22 @@
object->fetch.flags = flags;
object->fetch.referer = referer_clone;
object->fetch.post = post_clone;
+
+ return llcache_object_refetch(object);
+}
+
+/**
+ * (Re)fetch an object
+ *
+ * \param object Object to refetch
+ * \return NSERROR_OK on success, appropriate error otherwise
+ *
+ * \pre The fetch parameters in object->fetch must be populated
+ */
+nserror llcache_object_refetch(llcache_object *object)
+{
+ const char *urlenc = NULL;
+ struct form_successful_control *multipart = NULL;
if (object->fetch.post != NULL) {
if (object->fetch.post->type == LLCACHE_POST_URL_ENCODED)
@@ -667,9 +689,9 @@
object->fetch.fetch = fetch_start(object->url, object->fetch.referer,
llcache_fetch_callback, object,
- flags & LLCACHE_RETRIEVE_NO_ERROR_PAGES,
+ object->fetch.flags & LLCACHE_RETRIEVE_NO_ERROR_PAGES,
urlenc, multipart,
- flags & LLCACHE_RETRIEVE_VERIFIABLE,
+ object->fetch.flags & LLCACHE_RETRIEVE_VERIFIABLE,
NULL, /** \todo Remove parent from this API */
NULL /** \todo Generate cache-control headers */);
if (object->fetch.fetch == NULL)
@@ -892,8 +914,10 @@
object->source_len > handle->bytes) {
/* Emit HAD_DATA event */
event.type = LLCACHE_EVENT_HAD_DATA;
- event.data.buf = object->source_data + handle->bytes;
- event.data.len = object->source_len - handle->bytes;
+ event.data.data.buf =
+ object->source_data + handle->bytes;
+ event.data.data.len =
+ object->source_len - handle->bytes;
error = handle->cb(handle, &event, handle->pw);
if (error != NSERROR_OK)
@@ -970,6 +994,38 @@
}
/**
+ * Handle a query response
+ *
+ * \param proceed Whether to proceed with fetch
+ * \param cbpw Our context for query
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror llcache_query_handle_response(bool proceed, void *cbpw)
+{
+ nserror error;
+ llcache_event event;
+ llcache_object_user *user;
+ llcache_object *object = cbpw;
+
+ /* Refetch, using existing fetch parameters, if client allows us to */
+ if (proceed)
+ return llcache_object_refetch(object);
+
+ /* Inform client(s) that object fetch failed */
+ event.type = LLCACHE_EVENT_ERROR;
+ /** \todo More appropriate error message */
+ event.data.msg = messages_get("FetchFailed");
+
+ for (user = object->users; user != NULL; user = user->next) {
+ error = user->handle.cb(&user->handle, &event, user->handle.pw);
+ if (error != NSERROR_OK)
+ return error;
+ }
+
+ return NSERROR_OK;
+}
+
+/**
* Handler for fetch events
*
* \param msg Type of fetch event
@@ -982,6 +1038,8 @@
{
nserror error = NSERROR_OK;
llcache_object *object = p;
+ llcache_object_user *user;
+ llcache_event event;
switch (msg) {
/* 3xx responses */
@@ -994,22 +1052,14 @@
error = llcache_fetch_notmodified(object, &object);
break;
- /** \todo Handle the rest of the FETCH_ events */
-
/* Normal 2xx state machine */
- /** \todo Merge FETCH_TYPE and FETCH_HEADER? */
case FETCH_HEADER:
/* Received a fetch header */
object->fetch.state = LLCACHE_FETCH_HEADERS;
error = llcache_fetch_process_header(object, data, size);
- break;
case FETCH_TYPE:
- /* Determined MIME type for object */
- /* This is always emitted after all headers have been received
- * and immediately before the first FETCH_DATA event. ::data
- * specifies the detected type (defaulted, if no Content-Type
- * header) and ::size contains the Content-Length or 0. */
+ /** \todo Purge FETCH_TYPE completely */
break;
case FETCH_DATA:
/* Received some data */
@@ -1025,20 +1075,44 @@
llcache_object_cache_update(object);
break;
- /* Out-of-band progress information */
+ /* Out-of-band information */
+ case FETCH_ERROR:
+ /* An error occurred while fetching */
+ fetch_abort(object->fetch.fetch);
+ object->fetch.fetch = NULL;
+ /** \todo Ensure this object becomes stale */
+
+ event.type = LLCACHE_EVENT_ERROR;
+ event.data.msg = data;
+
+ for (user = object->users; user != NULL; user = user->next) {
+ error = user->handle.cb(&user->handle, &event,
+ user->handle.pw);
+ if (error != NSERROR_OK)
+ break;
+ }
+ break;
case FETCH_PROGRESS:
/* Progress update */
+ event.type = LLCACHE_EVENT_PROGRESS;
+ event.data.msg = data;
+
+ for (user = object->users; user != NULL; user = user->next) {
+ error = user->handle.cb(&user->handle, &event,
+ user->handle.pw);
+ if (error != NSERROR_OK)
+ break;
+ }
break;
/* Events requiring action */
- case FETCH_ERROR:
- /* An error occurred while fetching */
- break;
case FETCH_AUTH:
/* Need Authentication */
+ error = llcache_fetch_auth(object, data);
break;
case FETCH_CERT_ERR:
/* Something went wrong when validating TLS certificates */
+ error = llcache_fetch_cert_error(object, data, size);
break;
}
@@ -1426,3 +1500,107 @@
return NSERROR_OK;
}
+
+/**
+ * Handle an authentication request
+ *
+ * \param object Object being fetched
+ * \param realm Authentication realm
+ * \return NSERROR_OK on success, appropriate error otherwise.
+ */
+nserror llcache_fetch_auth(llcache_object *object, const char *realm)
+{
+ nserror error = NSERROR_OK;
+
+ /* Abort fetch for this object */
+ fetch_abort(object->fetch.fetch);
+ object->fetch.fetch = NULL;
+
+ if (query_cb != NULL) {
+ llcache_query query;
+
+ /* Destroy headers */
+ while (object->num_headers > 0) {
+ object->num_headers--;
+
+ free(object->headers[object->num_headers].name);
+ free(object->headers[object->num_headers].value);
+ }
+ free(object->headers);
+ object->headers = NULL;
+
+ /* Emit query for authentication details */
+ query.type = LLCACHE_QUERY_AUTH;
+ query.url = object->url;
+ query.data.auth.realm = realm;
+
+ error = query_cb(&query, query_cb_pw,
+ llcache_query_handle_response, object);
+ } else {
+ llcache_object_user *user;
+ llcache_event event;
+
+ /* Inform client(s) that object fetch failed */
+ event.type = LLCACHE_EVENT_ERROR;
+ /** \todo More appropriate error message */
+ event.data.msg = messages_get("FetchFailed");
+
+ for (user = object->users; user != NULL; user = user->next) {
+ error = user->handle.cb(&user->handle, &event,
+ user->handle.pw);
+ if (error != NSERROR_OK)
+ break;
+ }
+ }
+
+ return error;
+}
+
+/**
+ * Handle a TLS certificate verification failure
+ *
+ * \param object Object being fetched
+ * \param certs Certificate chain
+ * \param num Number of certificates in chain
+ * \return NSERROR_OK on success, appropriate error otherwise
+ */
+nserror llcache_fetch_cert_error(llcache_object *object,
+ const struct ssl_cert_info *certs, size_t num)
+{
+ nserror error = NSERROR_OK;
+
+ /* Abort fetch for this object */
+ fetch_abort(object->fetch.fetch);
+ object->fetch.fetch = NULL;
+
+ if (query_cb != NULL) {
+ llcache_query query;
+
+ /* Emit query for TLS */
+ query.type = LLCACHE_QUERY_SSL;
+ query.url = object->url;
+ query.data.ssl.certs = certs;
+ query.data.ssl.num = num;
+
+ error = query_cb(&query, query_cb_pw,
+ llcache_query_handle_response, object);
+ } else {
+ llcache_object_user *user;
+ llcache_event event;
+
+ /* Inform client(s) that object fetch failed */
+ event.type = LLCACHE_EVENT_ERROR;
+ /** \todo More appropriate error message */
+ event.data.msg = messages_get("FetchFailed");
+
+ for (user = object->users; user != NULL; user = user->next) {
+ error = user->handle.cb(&user->handle, &event,
+ user->handle.pw);
+ if (error != NSERROR_OK)
+ break;
+ }
+ }
+
+ return error;
+}
+
Modified: branches/jmb/new-cache/content/llcache.h
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/llcache....
==============================================================================
--- branches/jmb/new-cache/content/llcache.h (original)
+++ branches/jmb/new-cache/content/llcache.h Mon Oct 12 21:36:48 2009
@@ -55,16 +55,22 @@
typedef enum {
LLCACHE_EVENT_HAD_HEADERS, /**< Received all headers */
LLCACHE_EVENT_HAD_DATA, /**< Received some data */
- LLCACHE_EVENT_DONE /**< Finished fetching data */
+ LLCACHE_EVENT_DONE, /**< Finished fetching data */
+
+ LLCACHE_EVENT_ERROR, /**< An error occurred during fetch */
+ LLCACHE_EVENT_PROGRESS, /**< Fetch progress update */
} llcache_event_type;
/** Low-level cache events */
typedef struct {
llcache_event_type type; /**< Type of event */
- struct {
- const uint8_t *buf; /**< Buffer of data */
- size_t len; /**< Length of buffer, in bytes */
- } data; /**< Received data */
+ union {
+ struct {
+ const uint8_t *buf; /**< Buffer of data */
+ size_t len; /**< Length of buffer, in bytes */
+ } data; /**< Received data */
+ const char *msg; /**< Error or progress message */
+ } data; /**< Event data */
} llcache_event;
/**
13 years, 8 months
r9630 jmb - in /branches/jmb/new-cache: amiga/fetch_file.c beos/beos_fetch_rsrc.cpp content/fetchers/fetch_curl.c content/fetchers/fetch_data.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Oct 12 18:14:20 2009
New Revision: 9630
URL: http://source.netsurf-browser.org?rev=9630&view=rev
Log:
Stop issuing FETCH_TYPE messages.
Instead, make non-HTTP handlers emit Content-Type/Content-Length headers through FETCH_HEADER.
The low-level cache is responsible for making sense of all of this stuff, rather than the fetch protocol handlers.
Modified:
branches/jmb/new-cache/amiga/fetch_file.c
branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp
branches/jmb/new-cache/content/fetchers/fetch_curl.c
branches/jmb/new-cache/content/fetchers/fetch_data.c
Modified: branches/jmb/new-cache/amiga/fetch_file.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/amiga/fetch_file...
==============================================================================
--- branches/jmb/new-cache/amiga/fetch_file.c (original)
+++ branches/jmb/new-cache/amiga/fetch_file.c Mon Oct 12 18:14:20 2009
@@ -272,6 +272,7 @@
if(fetch->fh)
{
+ char header[64];
struct ExamineData *fib;
if(fib = ExamineObjectTags(EX_FileHandleInput,fetch->fh,TAG_DONE))
{
@@ -283,8 +284,18 @@
fetch->mimetype = fetch_mimetype(fetch->path);
LOG(("mimetype %s len %ld",fetch->mimetype,fetch->len));
- ami_fetch_file_send_callback(FETCH_TYPE,
- fetch, fetch->mimetype, (ULONG)fetch->len);
+ snprintf(header, sizeof header,
+ "Content-Type: %s",
+ fetch->mimetype);
+ ami_fetch_file_send_callback(FETCH_HEADER,
+ fetch, header, strlen(header));
+
+ snprintf(header, sizeof header,
+ "Content-Length: %ld",
+ fetch->len);
+ ami_fetch_file_send_callback(FETCH_HEADER,
+ fetch, header, strlen(header));
+
}
else
{
Modified: branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/beos/beos_fetch_...
==============================================================================
--- branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp (original)
+++ branches/jmb/new-cache/beos/beos_fetch_rsrc.cpp Mon Oct 12 18:14:20 2009
@@ -277,6 +277,8 @@
/* Only process non-aborted fetches */
if (!c->aborted && fetch_rsrc_process(c) == true) {
+ char header[64];
+
fetch_set_http_code(c->parent_fetch, 200);
LOG(("setting rsrc: MIME type to %s, length to %zd",
c->mimetype, c->datalen));
@@ -284,8 +286,16 @@
* Therefore, we _must_ check for this after _every_
* call to fetch_rsrc_send_callback().
*/
- fetch_rsrc_send_callback(FETCH_TYPE,
- c, c->mimetype, c->datalen);
+ snprintf(header, sizeof header, "Content-Type: %s",
+ c->mimetype);
+ fetch_rsrc_send_callback(FETCH_HEADER, c, header,
+ strlen(header));
+
+ snprintf(header, sizeof header, "Content-Length: %zd",
+ c->datalen);
+ fetch_rsrc_send_callback(FETCH_HEADER, c, header,
+ strlen(header));
+
if (!c->aborted) {
fetch_rsrc_send_callback(FETCH_DATA,
c, c->data, c->datalen);
Modified: branches/jmb/new-cache/content/fetchers/fetch_curl.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchers...
==============================================================================
--- branches/jmb/new-cache/content/fetchers/fetch_curl.c (original)
+++ branches/jmb/new-cache/content/fetchers/fetch_curl.c Mon Oct 12 18:14:20 2009
@@ -1081,10 +1081,7 @@
bool fetch_curl_process_headers(struct curl_fetch_info *f)
{
long http_code;
- const char *type;
CURLcode code;
- struct stat s;
- char *url_path = 0;
f->had_headers = true;
@@ -1107,13 +1104,14 @@
/* handle HTTP redirects (3xx response codes) */
if (300 <= http_code && http_code < 400 && f->location != 0) {
LOG(("FETCH_REDIRECT, '%s'", f->location));
- fetch_send_callback(FETCH_REDIRECT, f->fetch_handle, f->location, 0);
+ fetch_send_callback(FETCH_REDIRECT, f->fetch_handle,
+ f->location, 0);
return true;
}
/* handle HTTP 401 (Authentication errors) */
if (http_code == 401) {
- fetch_send_callback(FETCH_AUTH, f->fetch_handle, f->realm,0);
+ fetch_send_callback(FETCH_AUTH, f->fetch_handle, f->realm, 0);
return true;
}
@@ -1125,49 +1123,58 @@
return true;
}
- /* find MIME type from headers or filetype for local files */
- code = curl_easy_getinfo(f->curl_handle, CURLINFO_CONTENT_TYPE, &type);
- assert(code == CURLE_OK);
-
- if (strncmp(f->url, "file:///", 8) == 0)
- url_path = curl_unescape(f->url + 7,
- (int) strlen(f->url) - 7);
-
- if (url_path && stat(url_path, &s) == 0) {
- /* file: URL and file exists */
- /* create etag */
- char etag_buf[20];
- snprintf(etag_buf, sizeof etag_buf,
- "ETag: \"%10d\"", (int) s.st_mtime);
- /* And send it to the header handler */
- fetch_send_callback(FETCH_HEADER, f->fetch_handle, etag_buf,
- strlen(etag_buf));
-
- /* don't set last modified time so as to ensure that local
- * files are revalidated at all times. */
-
- /* If performed a conditional request and unmodified ... */
- if (f->last_modified && f->file_etag &&
- f->last_modified > s.st_mtime &&
- f->file_etag == s.st_mtime) {
- fetch_send_callback(FETCH_NOTMODIFIED, f->fetch_handle,
- 0, 0);
+ /* find MIME type from filetype for local files */
+ if (strncmp(f->url, "file:///", 8) == 0) {
+ struct stat s;
+ char *url_path = curl_unescape(f->url + 7,
+ (int) strlen(f->url + 7));
+
+ if (url_path != NULL && stat(url_path, &s) == 0) {
+ /* file: URL and file exists */
+ char header[64];
+ const char *type;
+
+ /* create etag */
+ snprintf(header, sizeof header,
+ "ETag: \"%10d\"", (int) s.st_mtime);
+ /* And send it to the header handler */
+ fetch_send_callback(FETCH_HEADER, f->fetch_handle,
+ header, strlen(header));
+
+ /* create Content-Type */
+ type = fetch_filetype(url_path);
+ snprintf(header, sizeof header,
+ "Content-Type: %s", type);
+ /* Send it to the header handler */
+ fetch_send_callback(FETCH_HEADER, f->fetch_handle,
+ header, strlen(header));
+
+ /* create Content-Length */
+ type = fetch_filetype(url_path);
+ snprintf(header, sizeof header,
+ "Content-Length: %ld", s.st_size);
+ /* Send it to the header handler */
+ fetch_send_callback(FETCH_HEADER, f->fetch_handle,
+ header, strlen(header));
+
+ /* don't set last modified time so as to ensure that
+ * local files are revalidated at all times. */
+
+ /* Report not modified, if appropriate */
+ if (f->last_modified && f->file_etag &&
+ f->last_modified > s.st_mtime &&
+ f->file_etag == s.st_mtime) {
+ fetch_send_callback(FETCH_NOTMODIFIED,
+ f->fetch_handle, 0, 0);
+ curl_free(url_path);
+ return true;
+ }
+ }
+
+ if (url_path != NULL)
curl_free(url_path);
- return true;
- }
- }
-
- if (type == 0) {
- type = "text/plain";
- if (url_path) {
- type = fetch_filetype(url_path);
- }
- }
-
- curl_free(url_path);
-
- LOG(("FETCH_TYPE, '%s'", type));
- fetch_send_callback(FETCH_TYPE, f->fetch_handle, type, f->content_length);
+ }
+
if (f->abort)
return true;
Modified: branches/jmb/new-cache/content/fetchers/fetch_data.c
URL: http://source.netsurf-browser.org/branches/jmb/new-cache/content/fetchers...
==============================================================================
--- branches/jmb/new-cache/content/fetchers/fetch_data.c (original)
+++ branches/jmb/new-cache/content/fetchers/fetch_data.c Mon Oct 12 18:14:20 2009
@@ -263,6 +263,8 @@
/* Only process non-aborted fetches */
if (!c->aborted && fetch_data_process(c) == true) {
+ char header[64];
+
fetch_set_http_code(c->parent_fetch, 200);
LOG(("setting data: MIME type to %s, length to %zd",
c->mimetype, c->datalen));
@@ -270,8 +272,16 @@
* Therefore, we _must_ check for this after _every_
* call to fetch_data_send_callback().
*/
- fetch_data_send_callback(FETCH_TYPE,
- c, c->mimetype, c->datalen);
+ snprintf(header, sizeof header, "Content-Type: %s",
+ c->mimetype);
+ fetch_data_send_callback(FETCH_HEADER, c, header,
+ strlen(header));
+
+ snprintf(header, sizeof header, "Content-Length: %zd",
+ c->datalen);
+ fetch_data_send_callback(FETCH_HEADER, c, header,
+ strlen(header));
+
if (!c->aborted) {
fetch_data_send_callback(FETCH_DATA,
c, c->data, c->datalen);
13 years, 8 months
r9629 jmb - /trunk/netsurf/css/select.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Oct 12 12:38:22 2009
New Revision: 9629
URL: http://source.netsurf-browser.org?rev=9629&view=rev
Log:
Log failures
Modified:
trunk/netsurf/css/select.c
Modified: trunk/netsurf/css/select.c
URL: http://source.netsurf-browser.org/trunk/netsurf/css/select.c?rev=9629&r1=...
==============================================================================
--- trunk/netsurf/css/select.c (original)
+++ trunk/netsurf/css/select.c Mon Oct 12 12:38:22 2009
@@ -27,6 +27,7 @@
#include "css/select.h"
#include "css/utils.h"
#include "desktop/options.h"
+#include "utils/log.h"
#include "utils/url.h"
#include "utils/utils.h"
@@ -139,17 +140,21 @@
error = css_stylesheet_create(CSS_LEVEL_DEFAULT, charset, url, NULL,
CSS_ORIGIN_AUTHOR, CSS_MEDIA_ALL, allow_quirks, true,
dict, alloc, pw, nscss_resolve_url, NULL, &sheet);
- if (error != CSS_OK)
+ if (error != CSS_OK) {
+ LOG(("Failed creating sheet: %d", error));
return NULL;
+ }
error = css_stylesheet_append_data(sheet, data, len);
if (error != CSS_OK && error != CSS_NEEDDATA) {
+ LOG(("failed appending data: %d", error));
css_stylesheet_destroy(sheet);
return NULL;
}
error = css_stylesheet_data_done(sheet);
if (error != CSS_OK) {
+ LOG(("failed completing parse: %d", error));
css_stylesheet_destroy(sheet);
return NULL;
}
13 years, 8 months
r9628 jmb - /trunk/libparserutils/src/input/filter.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Oct 12 11:56:30 2009
New Revision: 9628
URL: http://source.netsurf-browser.org?rev=9628&view=rev
Log:
Ensure we use the canonical charset name when invoking iconv_open()
Modified:
trunk/libparserutils/src/input/filter.c
Modified: trunk/libparserutils/src/input/filter.c
URL: http://source.netsurf-browser.org/trunk/libparserutils/src/input/filter.c...
==============================================================================
--- trunk/libparserutils/src/input/filter.c (original)
+++ trunk/libparserutils/src/input/filter.c Mon Oct 12 11:56:30 2009
@@ -393,7 +393,8 @@
}
input->cd = iconv_open(
- parserutils_charset_mibenum_to_name(input->int_enc), enc);
+ parserutils_charset_mibenum_to_name(input->int_enc),
+ parserutils_charset_mibenum_to_name(mibenum));
if (input->cd == (iconv_t) -1) {
return (errno == EINVAL) ? PARSERUTILS_BADENCODING
: PARSERUTILS_NOMEM;
13 years, 8 months
r9626 jmb - /trunk/tools/trace/
by netsurf@semichrome.net
Author: jmb
Date: Mon Oct 12 10:01:30 2009
New Revision: 9626
URL: http://source.netsurf-browser.org?rev=9626&view=rev
Log:
Ignore build directories
Modified:
trunk/tools/trace/ (props changed)
Propchange: trunk/tools/trace/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Oct 12 10:01:30 2009
@@ -1,0 +1,1 @@
+build-*
13 years, 8 months
r9625 jmb - /trunk/tools/trace/src/trace.c
by netsurf@semichrome.net
Author: jmb
Date: Mon Oct 12 10:00:26 2009
New Revision: 9625
URL: http://source.netsurf-browser.org?rev=9625&view=rev
Log:
Yet more fail
Modified:
trunk/tools/trace/src/trace.c
Modified: trunk/tools/trace/src/trace.c
URL: http://source.netsurf-browser.org/trunk/tools/trace/src/trace.c?rev=9625&...
==============================================================================
--- trunk/tools/trace/src/trace.c (original)
+++ trunk/tools/trace/src/trace.c Mon Oct 12 10:00:26 2009
@@ -1,8 +1,8 @@
#include <stdint.h>
#include <stdio.h>
-extern void __cyg_profile_enter(void *, void *);
-extern void __cyg_profile_exit(void *, void *);
+extern void __cyg_profile_func_enter(void *, void *);
+extern void __cyg_profile_func_exit(void *, void *);
extern void *image__ro__base;
extern void *image__ro__limit;
@@ -22,7 +22,7 @@
}
}
-void __cyg_profile_enter(void *fn_address, void *call_site)
+void __cyg_profile_func_enter(void *fn_address, void *call_site)
{
uint32_t i = depth;
@@ -41,7 +41,7 @@
depth++;
}
-void __cyg_profile_exit(void *fn_address, void *call_site)
+void __cyg_profile_func_exit(void *fn_address, void *call_site)
{
uint32_t i = depth;
13 years, 8 months