commit ff6245a43326a5cc40ef17627b2068da431d6eb9
parent 3390f10fe27cd11766c2225b73c8ad12fd706289
Author: Christian Grothoff <grothoff@gnunet.org>
Date: Mon, 26 Jan 2026 03:42:38 +0100
only return 304 if If-none-match was set to our Etag
Diffstat:
2 files changed, 49 insertions(+), 36 deletions(-)
diff --git a/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c b/src/backend/taler-merchant-httpd_private-get-instances-ID-kyc.c
@@ -399,6 +399,7 @@ resume_kyc_with_response (struct KycContext *kc)
{
struct GNUNET_ShortHashCode sh;
bool not_modified;
+ char *can;
if ( (! GNUNET_TIME_absolute_is_past (kc->timeout)) &&
( (NULL != kc->lp_not_status) ||
@@ -413,21 +414,16 @@ resume_kyc_with_response (struct KycContext *kc)
}
return;
}
- {
- char *can;
-
- can = TALER_JSON_canonicalize (kc->kycs_data);
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CRYPTO_kdf (&sh,
- sizeof (sh),
- "KYC-SALT",
- strlen ("KYC-SALT"),
- can,
- strlen (can),
- NULL,
- 0));
- GNUNET_free (can);
- }
+ can = TALER_JSON_canonicalize (kc->kycs_data);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (&sh,
+ sizeof (sh),
+ "KYC-SALT",
+ strlen ("KYC-SALT"),
+ can,
+ strlen (can),
+ NULL,
+ 0));
not_modified = kc->have_lp_not_etag &&
(0 == GNUNET_memcmp (&sh,
&kc->lp_not_etag));
@@ -441,10 +437,21 @@ resume_kyc_with_response (struct KycContext *kc)
MHD_suspend_connection (kc->connection);
kc->suspended = GNUNET_YES;
}
+ GNUNET_free (can);
return;
}
- // FIXME: should check that client set if-not-modified header to
- // our ETAG before going 304 here!
+ {
+ const char *inm;
+
+ inm = MHD_lookup_connection_value (kc->connection,
+ MHD_GET_ARGUMENT_KIND,
+ MHD_HTTP_HEADER_IF_NONE_MATCH);
+ if ( (NULL == inm) ||
+ (0 != strcmp (inm,
+ can)) )
+ not_modified = false; /* must return full response */
+ }
+ GNUNET_free (can);
kc->response_code = not_modified
? MHD_HTTP_NOT_MODIFIED
: MHD_HTTP_OK;
diff --git a/src/backend/taler-merchant-httpd_private-get-orders-ID.c b/src/backend/taler-merchant-httpd_private-get-orders-ID.c
@@ -873,22 +873,18 @@ check_reply (struct GetOrderRequestContext *gorc,
unsigned int http_response_code;
bool not_modified;
struct MHD_Response *response;
-
- {
- char *can;
-
- can = TALER_JSON_canonicalize (reply);
- GNUNET_assert (GNUNET_YES ==
- GNUNET_CRYPTO_kdf (&sh,
- sizeof (sh),
- "GOR-SALT",
- strlen ("GOR-SALT"),
- can,
- strlen (can),
- NULL,
- 0));
- GNUNET_free (can);
- }
+ char *can;
+
+ can = TALER_JSON_canonicalize (reply);
+ GNUNET_assert (GNUNET_YES ==
+ GNUNET_CRYPTO_kdf (&sh,
+ sizeof (sh),
+ "GOR-SALT",
+ strlen ("GOR-SALT"),
+ can,
+ strlen (can),
+ NULL,
+ 0));
not_modified = gorc->have_lp_not_etag &&
(0 == GNUNET_memcmp (&sh,
&gorc->lp_not_etag));
@@ -906,10 +902,21 @@ check_reply (struct GetOrderRequestContext *gorc,
gorc->phase = GOP_SUSPENDED_ON_UNPAID;
gorc->suspended = GNUNET_YES;
MHD_suspend_connection (gorc->sc.con);
+ GNUNET_free (can);
return;
}
- // FIXME: should check that client set if-not-modified header to
- // our ETAG before going 304 here!
+ {
+ const char *inm;
+
+ inm = MHD_lookup_connection_value (gorc->sc.con,
+ MHD_GET_ARGUMENT_KIND,
+ MHD_HTTP_HEADER_IF_NONE_MATCH);
+ if ( (NULL == inm) ||
+ (0 != strcmp (inm,
+ can)) )
+ not_modified = false; /* must return full response */
+ }
+ GNUNET_free (can);
http_response_code = not_modified
? MHD_HTTP_NOT_MODIFIED
: MHD_HTTP_OK;
@@ -1561,7 +1568,6 @@ static void
phase_reply_result (struct GetOrderRequestContext *gorc)
{
struct TMH_HandlerContext *hc = gorc->hc;
- MHD_RESULT ret;
char *order_status_url;
GNUNET_assert (gorc->paid);