aboutsummaryrefslogtreecommitdiff
path: root/http.h
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-04-23 05:09:53 +0200
committerXavier Del Campo Romero <xavi.dcr@tutanota.com>2023-04-23 05:09:53 +0200
commit011807e1d69d196cd0b9fd39a9899eb335c81abf (patch)
tree4f5060c6f48376709d1d463780f90618882d4068 /http.h
parent2e2c9b4c93e7469f290f6c9a2c89ed5e41c2cd54 (diff)
downloadslcl-011807e1d69d196cd0b9fd39a9899eb335c81abf.tar.gz
Support URL parameters
Now, http_payload includes a list of human-readable parameters that can be read (but not modified) by users. Given the following example link: /test?key1=value1&key2=value2 This will generate two parameters, with the following values: { .args = { [0] = {.key = "key1", .value = "value1"}, [1] = {.key = "key2", .value = "value2"} }, .n_args = 2 } As expected, if any URL parameters are given, struct http_payload member "resource" is accordingly trimmed so as not to include any parameters. Therefore, considering the example above: {.args = {...}, .resource = "/test"} Limitations: - Since the definition of struct http_arg is both shared by http.h (as a read-only pointer within struct http_payload) and http.c (as a read/write pointer within struct ctx), its members (namely key and value) must remain as read/write pointers, even if they must not be modified by users of http.h.
Diffstat (limited to 'http.h')
-rw-r--r--http.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/http.h b/http.h
index ed0770f..8b3a286 100644
--- a/http.h
+++ b/http.h
@@ -35,6 +35,13 @@ struct http_payload
} *files;
} post;
} u;
+
+ const struct http_arg
+ {
+ char *key, *value;
+ } *args;
+
+ size_t n_args;
};
#define HTTP_STATUSES \