1
0
Fork 0

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.
This commit is contained in:
Xavier Del Campo Romero 2023-09-07 13:43:48 +02:00
parent 083dedbb9d
commit 11df321eda
Signed by untrusted user: xavi
GPG Key ID: 84FF3612A9BF43F2
1 changed files with 17 additions and 1 deletions

View File

@ -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"};