summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/exchange/taler-exchange-httpd.c23
-rw-r--r--src/exchange/taler-exchange-httpd.h5
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-webhook.c23
-rw-r--r--src/kyclogic/plugin_kyclogic_kycaid.c3
4 files changed, 35 insertions, 19 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index 1118f7f99..7c7777561 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 5fa942b15..25e9e1105 100644
--- a/src/exchange/taler-exchange-httpd.h
+++ b/src/exchange/taler-exchange-httpd.h
@@ -199,6 +199,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
* clean up @a rh_ctx. Can be NULL.
diff --git a/src/exchange/taler-exchange-httpd_kyc-webhook.c b/src/exchange/taler-exchange-httpd_kyc-webhook.c
index 76adfcd83..8bd6d4bb2 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 726ba7ead..a8d6901c8 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,
"",