From f72305504d83034e0350d9291fdf8f54641ab764 Mon Sep 17 00:00:00 2001
From: Ole Loots
Date: Fri, 21 Dec 2012 06:39:51 +0100
Subject: Use multipart/form-data for data transmission. Requires some new
nsoption functions to be saved. (Conversion -> option name to index)
---
content/fetchers/about.c | 55 ++++++++++++++++++++++++++++++++++++++++++++----
1 file changed, 51 insertions(+), 4 deletions(-)
(limited to 'content/fetchers')
diff --git a/content/fetchers/about.c b/content/fetchers/about.c
index 81ff2e153..f0d7c9e77 100644
--- a/content/fetchers/about.c
+++ b/content/fetchers/about.c
@@ -71,6 +71,8 @@ struct fetch_about_context {
nsurl *url; /**< The full url the fetch refers to */
+ struct fetch_multipart_data *post_multipart; /**< Form data */
+
fetch_about_handler handler;
};
@@ -309,7 +311,43 @@ static bool fetch_about_config_handler(struct fetch_about_context *ctx)
int res = 0;
lwc_string *path;
url_func_result status;
+ struct fetch_multipart_data *post_item;
+ bool do_save = false;
+ bool valid_token = false;
+ char token[9] = {"12345678"};
+
+ /* save settings: */
+ post_item = ctx->post_multipart;
+ while (post_item != NULL) {
+
+ if (strcmp(post_item->name, "token") == 0
+ && sctrcmp(post_item->value, token) == 0) {
+ valid_token = true;
+ if (do_save == true) {
+ break;
+ }
+ }
+
+ if (strcmp(post_item->name, "action") == 0
+ && sctrcmp(post_item->value, "Save") == 0) {
+ do_save = true;
+ if (valid_token == true) {
+ break;
+ }
+ }
+ post_item = post_item->next;
+ }
+ if (do_save && valid_token) {
+ int opt = 0;
+ post_item = ctx->post_multipart;
+ while (post_item != NULL) {
+ printf("%s -> %s\n", post_item->name, post_item->value);
+ //opt = nsoption_get_index(post_item->name);
+ //nsoption_get_type(opt);
+ post_item = post_item->next;
+ }
+ }
/* content is going to return ok */
fetch_set_http_code(ctx->fetchh, code);
@@ -335,14 +373,15 @@ static bool fetch_about_config_handler(struct fetch_about_context *ctx)
"
\n"
"NetSurf Browser Config
\n"
#ifdef NS_WITH_INTERACTIVE_ABOUT_CONFIG
- "\n"
- "\n