diff options
-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 | ||||
-rw-r--r-- | css/css.c | 15 | ||||
-rw-r--r-- | debug/netsurfd.c | 5 | ||||
-rw-r--r-- | desktop/browser.c | 50 | ||||
-rw-r--r-- | desktop/browser.h | 8 | ||||
-rw-r--r-- | render/form.h | 1 | ||||
-rw-r--r-- | render/html.c | 30 | ||||
-rw-r--r-- | riscos/gui.h | 7 | ||||
-rw-r--r-- | riscos/history.c | 7 | ||||
-rw-r--r-- | riscos/mouseactions.c | 7 | ||||
-rw-r--r-- | riscos/window.c | 6 | ||||
-rw-r--r-- | utils/config.h | 3 |
15 files changed, 157 insertions, 35 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 @@ -170,7 +170,10 @@ void css_revive(struct content *c, unsigned int width, unsigned int height) c->data.css.import_content[i] = fetchcache( c->data.css.import_url[i], c->url, css_atimport_callback, c, (void*)i, - c->width, c->height, true, 0, 0 + c->width, c->height, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif @@ -340,7 +343,10 @@ void css_atimport(struct content *c, struct css_node *node) c->data.css.import_url[i] = url1; c->data.css.import_content[i] = fetchcache( c->data.css.import_url[i], c->url, css_atimport_callback, - c, (void*)i, c->width, c->height, true, 0, 0 + c, (void*)i, c->width, c->height, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif @@ -392,7 +398,10 @@ void css_atimport_callback(content_msg msg, struct content *css, c->data.css.import_url[i] = xstrdup(error); c->data.css.import_content[i] = fetchcache( c->data.css.import_url[i], c->url, css_atimport_callback, - c, (void*)i, css->width, css->height, true, 0, 0 + c, (void*)i, css->width, css->height, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif diff --git a/debug/netsurfd.c b/debug/netsurfd.c index 827d01b46..f26521654 100644 --- a/debug/netsurfd.c +++ b/debug/netsurfd.c @@ -48,7 +48,10 @@ int main(int argc, char *argv[]) break; url[strlen(url) - 1] = 0; destroyed = 0; - c = fetchcache(url, 0, callback, 0, 0, 100, 1000, false, 0, 0 + c = fetchcache(url, 0, callback, 0, 0, 100, 1000, false +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , true #endif diff --git a/desktop/browser.c b/desktop/browser.c index 3c4536d36..275de9558 100644 --- a/desktop/browser.c +++ b/desktop/browser.c @@ -43,8 +43,12 @@ static void browser_window_redraw_boxes(struct browser_window* bw, struct box_po static void browser_window_follow_link(struct browser_window* bw, unsigned long click_x, unsigned long click_y, int click_type); static void browser_window_open_location_post(struct browser_window* bw, - const char* url0, char *post_urlenc, - struct form_successful_control *post_multipart); + const char* url0 +#ifdef WITH_POST + , char *post_urlenc, + struct form_successful_control *post_multipart +#endif + ); static void browser_window_callback(content_msg msg, struct content *c, void *p1, void *p2, const char *error); static void download_window_callback(content_msg msg, struct content *c, @@ -233,8 +237,12 @@ void browser_window_destroy(struct browser_window* bw } void browser_window_open_location_historical(struct browser_window* bw, - const char* url, char *post_urlenc, - struct form_successful_control *post_multipart) + const char* url +#ifdef WITH_POST + , char *post_urlenc, + struct form_successful_control *post_multipart +#endif + ) { #ifdef WITH_AUTH struct login *li; @@ -265,8 +273,10 @@ void browser_window_open_location_historical(struct browser_window* bw, bw->time0 = clock(); bw->history_add = false; bw->loading_content = fetchcache(url, 0, browser_window_callback, bw, 0, - gui_window_get_width(bw->window), 0, false, - post_urlenc, post_multipart + gui_window_get_width(bw->window), 0, false +#ifdef WITH_POST + ,post_urlenc, post_multipart +#endif #ifdef WITH_COOKIES , true #endif @@ -285,12 +295,20 @@ void browser_window_open_location_historical(struct browser_window* bw, void browser_window_open_location(struct browser_window* bw, const char* url0) { - browser_window_open_location_post(bw, url0, 0, 0); + browser_window_open_location_post(bw, url0 +#ifdef WITH_POST + , 0, 0 +#endif + ); } void browser_window_open_location_post(struct browser_window* bw, - const char* url, char *post_urlenc, - struct form_successful_control *post_multipart) + const char* url +#ifdef WITH_POST + , char *post_urlenc, + struct form_successful_control *post_multipart +#endif + ) { char *url1; LOG(("bw = %p, url = %s", bw, url)); @@ -298,7 +316,11 @@ void browser_window_open_location_post(struct browser_window* bw, url1 = url_join(url, 0); if (!url1) return; - browser_window_open_location_historical(bw, url1, post_urlenc, post_multipart); + browser_window_open_location_historical(bw, url1 +#ifdef WITH_POST + , post_urlenc, post_multipart +#endif + ); bw->history_add = true; free(url1); LOG(("end")); @@ -1661,7 +1683,7 @@ void browser_form_submit(struct browser_window *bw, struct form *form, break; browser_window_open_location(bw, url1); break; - +#ifdef WITH_POST case method_POST_URLENC: data = form_url_encode(success); url = url_join(form->action, base); @@ -1674,7 +1696,11 @@ void browser_form_submit(struct browser_window *bw, struct form *form, url = url_join(form->action, base); browser_window_open_location_post(bw, url, 0, success); break; - +#else + case method_POST_URLENC: + case method_POST_MULTIPART: + break; +#endif default: assert(0); } diff --git a/desktop/browser.h b/desktop/browser.h index ada21a37b..ead88eb82 100644 --- a/desktop/browser.h +++ b/desktop/browser.h @@ -106,8 +106,12 @@ void browser_window_destroy(struct browser_window* bw ); void browser_window_open_location(struct browser_window* bw, const char* url); void browser_window_open_location_historical(struct browser_window* bw, - const char* url, char *post_urlenc, - struct form_successful_control *post_multipart); + const char* url +#ifdef WITH_POST + , char *post_urlenc, + struct form_successful_control *post_multipart +#endif + ); int browser_window_action(struct browser_window* bw, struct browser_action* act); void browser_window_set_status(struct browser_window* bw, const char* text); diff --git a/render/form.h b/render/form.h index 10e357ec7..53f933720 100644 --- a/render/form.h +++ b/render/form.h @@ -14,6 +14,7 @@ #define _NETSURF_RENDER_FORM_H_ #include <stdbool.h> +#include "netsurf/utils/config.h" struct box; struct form_control; diff --git a/render/html.c b/render/html.c index c7cb76ba3..9e447e4ae 100644 --- a/render/html.c +++ b/render/html.c @@ -203,7 +203,10 @@ void html_convert_css_callback(content_msg msg, struct content *css, c->active--; c->data.html.stylesheet_content[i] = fetchcache( error, c->url, html_convert_css_callback, - c, (void*)i, css->width, css->height, true, 0, 0 + c, (void*)i, css->width, css->height, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif @@ -280,7 +283,10 @@ void html_find_stylesheets(struct content *c, xmlNode *head) #endif c->url, html_convert_css_callback, - c, 0, c->width, c->height, true, 0, 0 + c, 0, c->width, c->height, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif @@ -338,7 +344,10 @@ void html_find_stylesheets(struct content *c, xmlNode *head) (i + 1) * sizeof(*c->data.html.stylesheet_content)); c->data.html.stylesheet_content[i] = fetchcache(url, c->url, html_convert_css_callback, c, (void*)i, - c->width, c->height, true, 0, 0 + c->width, c->height, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif @@ -432,7 +441,10 @@ void html_fetch_object(struct content *c, char *url, struct box *box) c->data.html.object[i].content = fetchcache(url, c->url, html_object_callback, c, (void*)i, c->width, c->height, - true, 0, 0 + true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif @@ -526,7 +538,10 @@ void html_object_callback(content_msg msg, struct content *object, c->data.html.object[i].url = xstrdup(error); c->data.html.object[i].content = fetchcache( error, c->url, html_object_callback, - c, (void*)i, 0, 0, true, 0, 0 + c, (void*)i, 0, 0, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif @@ -577,7 +592,10 @@ void html_revive(struct content *c, unsigned int width, unsigned int height) c->data.html.object[i].content = fetchcache( c->data.html.object[i].url, c->url, html_object_callback, - c, (void*)i, 0, 0, true, 0, 0 + c, (void*)i, 0, 0, true +#ifdef WITH_POST + , 0, 0 +#endif #ifdef WITH_COOKIES , false #endif diff --git a/riscos/gui.h b/riscos/gui.h index fa0b783c3..a943851b8 100644 --- a/riscos/gui.h +++ b/riscos/gui.h @@ -166,6 +166,13 @@ void ro_gui_history_click(wimp_pointer *pointer); #define ICON_TOOLBAR_STATUS 3 #define ICON_TOOLBAR_HISTORY 4 #define ICON_TOOLBAR_RELOAD 5 +#define ICON_TOOLBAR_STOP 6 +#define ICON_TOOLBAR_BACK 7 +#define ICON_TOOLBAR_FORWARD 8 +#define ICON_TOOLBAR_BOOKMARK 9 +#define ICON_TOOLBAR_SAVE 10 +#define ICON_TOOLBAR_PRINT 11 +#define ICON_TOOLBAR_HOME 12 #define ICON_CONFIG_SAVE 0 #define ICON_CONFIG_CANCEL 1 diff --git a/riscos/history.c b/riscos/history.c index 42711a20c..49fbf956f 100644 --- a/riscos/history.c +++ b/riscos/history.c @@ -10,6 +10,7 @@ #include "oslib/colourtrans.h" #include "oslib/font.h" #include "oslib/wimp.h" +#include "netsurf/utils/config.h" #include "netsurf/riscos/gui.h" #include "netsurf/utils/log.h" #include "netsurf/utils/utils.h" @@ -256,7 +257,11 @@ void ro_gui_history_click(wimp_pointer *pointer) history_bw->history_entry = he; wimp_create_menu(wimp_CLOSE_MENU, 0, 0); browser_window_open_location_historical(history_bw, - he->url, 0, 0); + he->url +#ifdef WITH_POST + , 0, 0 +#endif + ); } } diff --git a/riscos/mouseactions.c b/riscos/mouseactions.c index b5e3fc550..9c7f76ea6 100644 --- a/riscos/mouseactions.c +++ b/riscos/mouseactions.c @@ -9,6 +9,7 @@ #include "oslib/os.h" +#include "netsurf/utils/config.h" #include "netsurf/desktop/browser.h" #include "netsurf/desktop/options.h" #include "netsurf/riscos/gui.h" @@ -56,7 +57,11 @@ void ro_gui_mouse_action(gui_window *g) { case mouseaction_RELOAD: browser_window_open_location_historical(g->data.browser.bw, - g->data.browser.bw->url, 0, 0); + g->data.browser.bw->url +#ifdef WITH_POST + , 0, 0 +#endif + ); break; default: break; diff --git a/riscos/window.c b/riscos/window.c index ddee5cedf..540f7000a 100644 --- a/riscos/window.c +++ b/riscos/window.c @@ -565,7 +565,11 @@ void ro_gui_toolbar_click(gui_window* g, wimp_pointer* pointer) break; case ICON_TOOLBAR_RELOAD: browser_window_open_location_historical(g->data.browser.bw, - g->data.browser.bw->url, 0, 0); + g->data.browser.bw->url +#ifdef WITH_POST + , 0, 0 +#endif + ); break; } } diff --git a/utils/config.h b/utils/config.h index c26ed3f50..66c1a20b6 100644 --- a/utils/config.h +++ b/utils/config.h @@ -12,6 +12,9 @@ * Simply undefine a symbol to turn the relevant feature off. */ +/* HTTP POST support */ +#define WITH_POST + /* Image renderering modules */ #define WITH_DRAW #define WITH_GIF |