From 11df321edaae2e0eae9603ea333cc19535b9eab6 Mon Sep 17 00:00:00 2001 From: Xavier Del Campo Romero Date: Thu, 7 Sep 2023 13:43:48 +0200 Subject: hello/main.c: Add missing length callback Even if the feature is unsupported by the application, slweb requires `length` to be a valid function pointer. --- examples/hello/main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'examples') diff --git a/examples/hello/main.c b/examples/hello/main.c index f44ff0c..d1a3206 100644 --- a/examples/hello/main.c +++ b/examples/hello/main.c @@ -66,11 +66,27 @@ end: return ret; } +static int on_length(const unsigned long long len, + const struct http_cookie *const c, struct http_response *const r, + void *const user) +{ + *r = (const struct http_response) + { + .status = HTTP_STATUS_FORBIDDEN + }; + + return 1; +} + int main(int argc, char *argv[]) { int ret = EXIT_FAILURE; const short port = 8080; - const struct handler_cfg cfg = {0}; + const struct handler_cfg cfg = + { + .length = on_length + }; + struct handler *const h = handler_alloc(&cfg); static const char *const urls[] = {"/", "/index.html"}; -- cgit v1.2.3