gnunet-svn
[Top][All Lists]
Advanced

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

[taler-exchange] branch master updated: fix cases where POST does not wo


From: gnunet
Subject: [taler-exchange] branch master updated: fix cases where POST does not work in one-shot after upload is complete
Date: Sun, 12 Nov 2023 15:36:04 +0100

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

grothoff pushed a commit to branch master
in repository exchange.

The following commit(s) were added to refs/heads/master by this push:
     new ab208ab6 fix cases where POST does not work in one-shot after upload 
is complete
ab208ab6 is described below

commit ab208ab685d2dde0612c6784834bf6552b96f5b4
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Nov 12 15:36:00 2023 +0100

    fix cases where POST does not work in one-shot after upload is complete
---
 src/exchange/taler-exchange-httpd.c             | 23 +++++++++++++----------
 src/exchange/taler-exchange-httpd.h             |  5 +++++
 src/exchange/taler-exchange-httpd_kyc-webhook.c | 23 ++++++++++++++---------
 src/kyclogic/plugin_kyclogic_kycaid.c           |  3 +++
 4 files changed, 35 insertions(+), 19 deletions(-)

diff --git a/src/exchange/taler-exchange-httpd.c 
b/src/exchange/taler-exchange-httpd.c
index 1118f7f9..7c777756 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -1022,6 +1022,11 @@ handle_mhd_completion_callback (void *cls,
   TEH_check_invariants ();
   if (NULL != rc->rh_cleaner)
     rc->rh_cleaner (rc);
+  if (NULL != rc->root)
+  {
+    json_decref (rc->root);
+    rc->root = NULL;
+  }
   TEH_check_invariants ();
   {
 #if MHD_VERSION >= 0x00097304
@@ -1088,7 +1093,6 @@ proceed_with_handler (struct TEH_RequestContext *rc,
   const struct TEH_RequestHandler *rh = rc->rh;
   const char *args[rh->nargs + 2];
   size_t ulen = strlen (url) + 1;
-  json_t *root = NULL;
   MHD_RESULT ret;
 
   /* We do check for "ulen" here, because we'll later stack-allocate a buffer
@@ -1109,8 +1113,9 @@ proceed_with_handler (struct TEH_RequestContext *rc,
 
   /* All POST endpoints come with a body in JSON format. So we parse
      the JSON here. */
-  if (0 == strcasecmp (rh->method,
-                       MHD_HTTP_METHOD_POST))
+  if ( (0 == strcasecmp (rh->method,
+                         MHD_HTTP_METHOD_POST)) &&
+       (NULL == rc->root) )
   {
     enum GNUNET_GenericReturnValue res;
 
@@ -1118,16 +1123,16 @@ proceed_with_handler (struct TEH_RequestContext *rc,
                                      &rc->opaque_post_parsing_context,
                                      upload_data,
                                      upload_data_size,
-                                     &root);
+                                     &rc->root);
     if (GNUNET_SYSERR == res)
     {
-      GNUNET_assert (NULL == root);
+      GNUNET_assert (NULL == rc->root);
       return MHD_NO; /* bad upload, could not even generate error */
     }
     if ( (GNUNET_NO == res) ||
-         (NULL == root) )
+         (NULL == rc->root) )
     {
-      GNUNET_assert (NULL == root);
+      GNUNET_assert (NULL == rc->root);
       return MHD_YES; /* so far incomplete upload or parser error */
     }
   }
@@ -1164,7 +1169,6 @@ proceed_with_handler (struct TEH_RequestContext *rc,
                        rh->url,
                        url);
       GNUNET_break_op (0);
-      json_decref (root);
       return TALER_MHD_reply_with_error (rc->connection,
                                          MHD_HTTP_NOT_FOUND,
                                          
TALER_EC_EXCHANGE_GENERIC_WRONG_NUMBER_OF_SEGMENTS,
@@ -1177,7 +1181,7 @@ proceed_with_handler (struct TEH_RequestContext *rc,
     if (0 == strcasecmp (rh->method,
                          MHD_HTTP_METHOD_POST))
       ret = rh->handler.post (rc,
-                              root,
+                              rc->root,
                               args);
     else if (0 == strcasecmp (rh->method,
                               MHD_HTTP_METHOD_DELETE))
@@ -1187,7 +1191,6 @@ proceed_with_handler (struct TEH_RequestContext *rc,
       ret = rh->handler.get (rc,
                              args);
   }
-  json_decref (root);
   return ret;
 }
 
diff --git a/src/exchange/taler-exchange-httpd.h 
b/src/exchange/taler-exchange-httpd.h
index 5fa942b1..25e9e110 100644
--- a/src/exchange/taler-exchange-httpd.h
+++ b/src/exchange/taler-exchange-httpd.h
@@ -198,6 +198,11 @@ struct TEH_RequestContext
    */
   struct MHD_Connection *connection;
 
+  /**
+   * JSON root of uploaded data (or NULL, if none).
+   */
+  json_t *root;
+
   /**
    * @e rh-specific cleanup routine. Function called
    * upon completion of the request that should
diff --git a/src/exchange/taler-exchange-httpd_kyc-webhook.c 
b/src/exchange/taler-exchange-httpd_kyc-webhook.c
index 76adfcd8..8bd6d4bb 100644
--- a/src/exchange/taler-exchange-httpd_kyc-webhook.c
+++ b/src/exchange/taler-exchange-httpd_kyc-webhook.c
@@ -227,8 +227,9 @@ webhook_finished_cb (
       response = TALER_MHD_make_error (
         TALER_EC_EXCHANGE_GENERIC_BAD_CONFIGURATION,
         "[exchange] AML_KYC_TRIGGER");
+      break;
     }
-    break;
+    return;
   default:
     GNUNET_log (GNUNET_ERROR_TYPE_INFO,
                 "KYC status of %s/%s (Row #%llu) is %d\n",
@@ -238,10 +239,10 @@ webhook_finished_cb (
                 status);
     break;
   }
-  if (NULL == kwh->kat)
-    kyc_aml_webhook_finished (kwh,
-                              http_status,
-                              response);
+  GNUNET_break (NULL == kwh->kat);
+  kyc_aml_webhook_finished (kwh,
+                            http_status,
+                            response);
 }
 
 
@@ -343,13 +344,17 @@ handler_kyc_webhook_generic (
     MHD_suspend_connection (rc->connection);
     return MHD_YES;
   }
+  GNUNET_break (GNUNET_NO == kwh->suspended);
 
   if (NULL != kwh->response)
   {
-    /* handle _failed_ resumed cases */
-    return MHD_queue_response (rc->connection,
-                               kwh->response_code,
-                               kwh->response);
+    MHD_RESULT res;
+
+    res = MHD_queue_response (rc->connection,
+                              kwh->response_code,
+                              kwh->response);
+    GNUNET_break (MHD_YES == res);
+    return res;
   }
 
   /* We resumed, but got no response? This should
diff --git a/src/kyclogic/plugin_kyclogic_kycaid.c 
b/src/kyclogic/plugin_kyclogic_kycaid.c
index 726ba7ea..a8d6901c 100644
--- a/src/kyclogic/plugin_kyclogic_kycaid.c
+++ b/src/kyclogic/plugin_kyclogic_kycaid.c
@@ -1329,6 +1329,9 @@ kycaid_webhook (void *cls,
     /* We don't need to re-confirm the failure by
        asking the API again. */
     log_failure (verifications);
+    GNUNET_log (GNUNET_ERROR_TYPE_INFO,
+                "Webhook called with non-completion status: %s\n",
+                type);
     wh->response_code = MHD_HTTP_NO_CONTENT;
     wh->resp = MHD_create_response_from_buffer (0,
                                                 "",

-- 
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]