challenger

OAuth 2.0-based authentication service that validates user can receive messages at a certain address
Log | Files | Refs | Submodules | README | LICENSE

commit ff79e455b8947581000f2e4afb992938909224b9
parent 9046d46b17c89514d0bc0867e032df46af3ad518
Author: Christian Grothoff <grothoff@gnunet.org>
Date:   Wed, 26 Apr 2023 08:49:18 +0200

implement url prefix matching

Diffstat:
Msrc/challenger/challenger-httpd.c | 16++++++++++------
Msrc/challenger/challenger-httpd.h | 11+++++++++--
2 files changed, 19 insertions(+), 8 deletions(-)

diff --git a/src/challenger/challenger-httpd.c b/src/challenger/challenger-httpd.c @@ -222,8 +222,13 @@ url_handler (void *cls, { struct CH_RequestHandler *rh = &handlers[i]; - if (0 == strcmp (url, - rh->url)) + if ( (0 == strcmp (url, + rh->url)) || + ( (0 == strncmp (url, + rh->url, + strlen (rh->url))) && + (1 < strlen (rh->url)) && + ('/' == rh->url[strlen (rh->url) - 1]) ) ) { found = true; if (0 == strcasecmp (method, @@ -231,9 +236,8 @@ url_handler (void *cls, { return TALER_MHD_reply_cors_preflight (connection); } - if ( (NULL == rh->method) || - (0 == strcasecmp (method, - rh->method)) ) + if (0 == strcasecmp (method, + rh->method)) { hc->rh = rh; break; @@ -264,6 +268,7 @@ url_handler (void *cls, GNUNET_SCHEDULER_begin_async_scope (&hc->async_scope_id); } GNUNET_assert (NULL != hc->rh); + hc->path = &url[strlen (rh->url)]; return hc->rh->handler (hc, upload_data, upload_data_size); @@ -279,7 +284,6 @@ static void do_shutdown (void *cls) { (void) cls; - // CH_resume_all_bc (); if (NULL != mhd_task) { GNUNET_SCHEDULER_cancel (mhd_task); diff --git a/src/challenger/challenger-httpd.h b/src/challenger/challenger-httpd.h @@ -70,6 +70,11 @@ struct CH_HandlerContext struct MHD_Connection *connection; /** + * remaining URL path + */ + const char *path; + + /** * Request handler for this request. */ const struct CH_RequestHandler *rh; @@ -88,12 +93,14 @@ struct CH_RequestHandler { /** - * URL the handler is for. + * URL the handler is for. End with a '/' to make + * this only a prefix to match. However, "/" will + * only match "/" and not be treated as a prefix. */ const char *url; /** - * Method the handler is for, NULL for "all". + * HTTP method the handler is for. */ const char *method;