aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2024-08-08 09:47:10 +0200
committerChristian Grothoff <christian@grothoff.org>2024-08-08 09:47:10 +0200
commita9a40d1e58f0b2d48285511dc8f216f6d99e115d (patch)
treef24d5367d7c08760ca46004bba88a444ef386e50
parentc08266947f14ee390cbc37a8dd70746215361e8e (diff)
fix Etag for kyc-info endpoint
-rw-r--r--src/exchange/taler-exchange-httpd_kyc-info.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/exchange/taler-exchange-httpd_kyc-info.c b/src/exchange/taler-exchange-httpd_kyc-info.c
index 88c9fc579..2b62455a0 100644
--- a/src/exchange/taler-exchange-httpd_kyc-info.c
+++ b/src/exchange/taler-exchange-httpd_kyc-info.c
@@ -176,6 +176,25 @@ db_event_cb (void *cls,
/**
+ * Add the headers we want to set for every response.
+ *
+ * @param cls the key state to use
+ * @param[in,out] response the response to modify
+ */
+static void
+add_response_headers (void *cls,
+ struct MHD_Response *response)
+{
+ (void) cls;
+ TALER_MHD_add_global_headers (response);
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CACHE_CONTROL,
+ "no-cache"));
+}
+
+
+/**
* Generate a reply with the KycProcessClientInformation from
* the LegitimizationMeasures.
*
@@ -277,7 +296,7 @@ generate_reply (struct KycPoller *kyp,
GNUNET_snprintf (etags,
sizeof (etags),
- "%llu",
+ "\"%llu\"",
(unsigned long long) legitimization_measure_row_id);
resp = TALER_MHD_MAKE_JSON_PACK (
GNUNET_JSON_pack_array_steal ("requirements",
@@ -292,6 +311,8 @@ generate_reply (struct KycPoller *kyp,
MHD_add_response_header (resp,
MHD_HTTP_HEADER_ETAG,
etags));
+ add_response_headers (NULL,
+ resp);
res = MHD_queue_response (kyp->connection,
MHD_HTTP_OK,
resp);
@@ -441,7 +462,21 @@ TEH_handler_kyc_info (
MHD_suspend_connection (rc->connection);
return MHD_YES;
}
+ if (legitimization_measure_last_row == kyp->etag_in)
+ {
+ char etags[64];
+ json_decref (jmeasures);
+ GNUNET_snprintf (etags,
+ sizeof (etags),
+ "\"%llu\"",
+ (unsigned long long) legitimization_measure_last_row);
+ return TEH_RESPONSE_reply_not_modified (
+ rc->connection,
+ etags,
+ &add_response_headers,
+ NULL);
+ }
res = generate_reply (kyp,
legitimization_measure_last_row,
jmeasures);