diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2004-01-20 19:08:34 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2004-01-20 19:08:34 +0000 |
commit | 0dab93fe7652dd1f1c656356a62f01d4053bb2ff (patch) | |
tree | 3b3d7bc784d3f39f2474b231e4727288144b5902 /content | |
parent | 10b546f7f974ac8e157426ee42d7abdd52dbf14b (diff) | |
download | netsurf-0dab93fe7652dd1f1c656356a62f01d4053bb2ff.tar.gz netsurf-0dab93fe7652dd1f1c656356a62f01d4053bb2ff.tar.bz2 |
[project @ 2004-01-20 19:08:34 by jmb]
Allow toggling of POST support.
Add new toolbar icon numbers to riscos/gui.h
svn path=/import/netsurf/; revision=490
Diffstat (limited to 'content')
-rw-r--r-- | content/fetch.c | 23 | ||||
-rw-r--r-- | content/fetch.h | 7 | ||||
-rw-r--r-- | content/fetchcache.c | 16 | ||||
-rw-r--r-- | content/fetchcache.h | 7 |
4 files changed, 45 insertions, 8 deletions
diff --git a/content/fetch.c b/content/fetch.c index 87dbe79f5..97e0473b8 100644 --- a/content/fetch.c +++ b/content/fetch.c @@ -36,7 +36,9 @@ #ifdef WITH_AUTH #include "netsurf/desktop/401login.h" #endif +#ifdef WITH_POST #include "netsurf/render/form.h" +#endif #include "netsurf/utils/log.h" #include "netsurf/utils/messages.h" #include "netsurf/utils/utils.h" @@ -64,8 +66,10 @@ struct fetch { #ifdef WITH_AUTH char *realm; /**< HTTP Auth Realm */ #endif +#ifdef WITH_POST char *post_urlenc; /**< Url encoded POST string, or 0. */ struct HttpPost *post_multipart; /**< Multipart post data, or 0. */ +#endif struct fetch *queue_prev; /**< Previous fetch for this host. */ struct fetch *queue_next; /**< Next fetch for this host. */ struct fetch *prev; /**< Previous active fetch in ::fetch_list. */ @@ -79,7 +83,9 @@ static struct fetch *fetch_list = 0; /**< List of active fetches. */ static size_t fetch_curl_data(void * data, size_t size, size_t nmemb, struct fetch *f); static size_t fetch_curl_header(char * data, size_t size, size_t nmemb, struct fetch *f); static bool fetch_process_headers(struct fetch *f); +#ifdef WITH_POST static struct HttpPost *fetch_post_convert(struct form_successful_control *control); +#endif #ifdef riscos static char * ca_bundle; /**< SSL certificate bundle filename. */ @@ -155,8 +161,11 @@ void fetch_quit(void) struct fetch * fetch_start(char *url, char *referer, void (*callback)(fetch_msg msg, void *p, char *data, unsigned long size), - void *p, bool only_2xx, char *post_urlenc, + void *p, bool only_2xx +#ifdef WITH_POST + , char *post_urlenc, struct form_successful_control *post_multipart +#endif #ifdef WITH_COOKIES , bool cookies #endif @@ -194,12 +203,14 @@ struct fetch * fetch_start(char *url, char *referer, if (uri->server != 0) fetch->host = xstrdup(uri->server); fetch->content_length = 0; +#ifdef WITH_POST fetch->post_urlenc = 0; fetch->post_multipart = 0; if (post_urlenc) fetch->post_urlenc = xstrdup(post_urlenc); else if (post_multipart) fetch->post_multipart = fetch_post_convert(post_multipart); +#endif fetch->queue_prev = 0; fetch->queue_next = 0; fetch->prev = 0; @@ -301,6 +312,7 @@ struct fetch * fetch_start(char *url, char *referer, #endif /* POST */ +#ifdef WITH_POST if (fetch->post_urlenc) { code = curl_easy_setopt(fetch->curl_handle, CURLOPT_POSTFIELDS, fetch->post_urlenc); @@ -310,6 +322,7 @@ struct fetch * fetch_start(char *url, char *referer, CURLOPT_HTTPPOST, fetch->post_multipart); assert(code == CURLE_OK); } +#endif /* Cookies */ #ifdef WITH_COOKIES @@ -410,6 +423,7 @@ void fetch_abort(struct fetch *f) #endif /* POST */ +#ifdef WITH_POST if (fetch->post_urlenc) { code = curl_easy_setopt(fetch->curl_handle, CURLOPT_POSTFIELDS, fetch->post_urlenc); @@ -424,6 +438,7 @@ void fetch_abort(struct fetch *f) code = curl_easy_setopt(fetch->curl_handle, CURLOPT_HTTPPOST, 0); assert(code == CURLE_OK); } +#endif /* add to the global curl multi handle */ codem = curl_multi_add_handle(curl_multi, fetch->curl_handle); @@ -447,9 +462,11 @@ void fetch_abort(struct fetch *f) #ifdef WITH_AUTH free(f->realm); #endif +#ifdef WITH_POST free(f->post_urlenc); if (f->post_multipart) curl_formfree(f->post_multipart); +#endif xfree(f); } @@ -658,7 +675,7 @@ bool fetch_process_headers(struct fetch *f) * Convert a list of struct ::form_successful_control to a list of * struct HttpPost for libcurl. */ - +#ifdef WITH_POST struct HttpPost *fetch_post_convert(struct form_successful_control *control) { struct HttpPost *post = 0, *last = 0; @@ -672,7 +689,7 @@ struct HttpPost *fetch_post_convert(struct form_successful_control *control) return post; } - +#endif /** * testing framework diff --git a/content/fetch.h b/content/fetch.h index 5075f6058..098ab39d1 100644 --- a/content/fetch.h +++ b/content/fetch.h @@ -28,15 +28,20 @@ typedef enum { struct content; struct fetch; +#ifdef WITH_POST struct form_successful_control; +#endif extern bool fetch_active; void fetch_init(void); struct fetch * fetch_start(char *url, char *referer, void (*callback)(fetch_msg msg, void *p, char *data, unsigned long size), - void *p, bool only_2xx, char *post_urlenc, + void *p, bool only_2xx +#ifdef WITH_POST + , char *post_urlenc, struct form_successful_control *post_multipart +#endif #ifdef WITH_COOKIES ,bool cookies #endif diff --git a/content/fetchcache.c b/content/fetchcache.c index b3eac27fa..4cec561dc 100644 --- a/content/fetchcache.c +++ b/content/fetchcache.c @@ -47,8 +47,11 @@ struct content * fetchcache(const char *url0, char *referer, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), void *p1, void *p2, unsigned long width, unsigned long height, - bool only_2xx, char *post_urlenc, + bool only_2xx +#ifdef WITH_POST + , char *post_urlenc, struct form_successful_control *post_multipart +#endif #ifdef WITH_COOKIES ,bool cookies #endif @@ -64,6 +67,7 @@ struct content * fetchcache(const char *url0, char *referer, LOG(("url %s", url)); +#ifdef WITH_POST if (!post_urlenc && !post_multipart) { c = cache_get(url); if (c != 0) { @@ -72,16 +76,22 @@ struct content * fetchcache(const char *url0, char *referer, return c; } } +#endif c = content_create(url); content_add_user(c, callback, p1, p2); + +#ifdef WITH_POST if (!post_urlenc && !post_multipart) cache_put(c); +#endif c->fetch_size = 0; c->width = width; c->height = height; - c->fetch = fetch_start(url, referer, fetchcache_callback, c, only_2xx, - post_urlenc, post_multipart + c->fetch = fetch_start(url, referer, fetchcache_callback, c, only_2xx +#ifdef WITH_POST + ,post_urlenc, post_multipart +#endif #ifdef WITH_COOKIES ,cookies #endif diff --git a/content/fetchcache.h b/content/fetchcache.h index bc1cfb76e..cbd447aa1 100644 --- a/content/fetchcache.h +++ b/content/fetchcache.h @@ -19,14 +19,19 @@ #include "netsurf/utils/config.h" #include "netsurf/content/content.h" +#ifdef WITH_POST struct form_successful_control; +#endif struct content * fetchcache(const char *url, char *referer, void (*callback)(content_msg msg, struct content *c, void *p1, void *p2, const char *error), void *p1, void *p2, unsigned long width, unsigned long height, - bool only_2xx, char *post_urlenc, + bool only_2xx +#ifdef WITH_POST + , char *post_urlenc, struct form_successful_control *post_multipart +#endif #ifdef WITH_COOKIES ,bool cookies #endif |