aboutsummaryrefslogtreecommitdiff
path: root/examples/form/README.md
diff options
context:
space:
mode:
authorXavier Del Campo Romero <xavi92@disroot.org>2025-09-30 23:50:33 +0200
committerXavier Del Campo Romero <xavi92@disroot.org>2025-10-02 15:52:14 +0200
commita0f5f7509bb9040752fa61fe0fdb447608e22b1c (patch)
tree53337bce28ed75f26953c5969af6bc76d8841f2b /examples/form/README.md
parentbba0b62f4e9e17927b9a2cda51dd5a4aa1b1f14e (diff)
Implement form interface
This new interface allows library users to parse application/x-www-form-urlencoded data conveniently.
Diffstat (limited to 'examples/form/README.md')
-rw-r--r--examples/form/README.md39
1 files changed, 39 insertions, 0 deletions
diff --git a/examples/form/README.md b/examples/form/README.md
new file mode 100644
index 0000000..6be1969
--- /dev/null
+++ b/examples/form/README.md
@@ -0,0 +1,39 @@
+# HTML forms example
+
+This example shows how to parse `application/x-www-form-urlencoded`-encoded
+data using `libweb`s `form` API, using untrusted user input.
+
+## How to build
+
+If using `make(1)`, just run `make` from this directory.
+
+If using CMake, examples are built by default when configuring the project
+from [the top-level `CMakeLists.txt`](../../CMakeLists.txt).
+
+## How to run
+
+Run the executable with a `application/x-www-form-urlencoded`-encoded given
+as its only argument.
+
+For example:
+
+```sh
+$ ./form 'username=admin&password=mypassword'
+```
+
+Shall return:
+
+```
+key=username, value=admin, cnt=1
+key=password, value=mypassword, cnt=2
+```
+
+An invalid string shall be reported to `stderr`:
+
+```sh
+$ ./form 'username=admin&thisisawrongvalue'
+```
+
+```
+main: invalid user input: username=admin&thisisawrongvalue
+```