gnunet-svn
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[taler-challenger] branch master updated: implement url prefix matching


From: gnunet
Subject: [taler-challenger] branch master updated: implement url prefix matching
Date: Wed, 26 Apr 2023 09:23:11 +0200

This is an automated email from the git hooks/post-receive script.

grothoff pushed a commit to branch master
in repository challenger.

The following commit(s) were added to refs/heads/master by this push:
     new ff79e45  implement url prefix matching
ff79e45 is described below

commit ff79e455b8947581000f2e4afb992938909224b9
Author: Christian Grothoff <grothoff@gnunet.org>
AuthorDate: Wed Apr 26 08:49:18 2023 +0200

    implement url prefix matching
---
 src/challenger/challenger-httpd.c | 16 ++++++++++------
 src/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
index f7d937c..68a93d1 100644
--- 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
index 6578507..3baef54 100644
--- a/src/challenger/challenger-httpd.h
+++ b/src/challenger/challenger-httpd.h
@@ -69,6 +69,11 @@ struct CH_HandlerContext
    */
   struct MHD_Connection *connection;
 
+  /**
+   * remaining URL path
+   */
+  const char *path;
+
   /**
    * Request handler for this request.
    */
@@ -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;
 

-- 
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]