[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[taler-challenger] branch master updated: add cache control to /config e
From: |
gnunet |
Subject: |
[taler-challenger] branch master updated: add cache control to /config endpoint |
Date: |
Sun, 21 Apr 2024 10:26:40 +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 f57b798 add cache control to /config endpoint
f57b798 is described below
commit f57b7984c77206f74fdd7b7ebb777c8a063c98d9
Author: Christian Grothoff <christian@grothoff.org>
AuthorDate: Sun Apr 21 10:26:38 2024 +0200
add cache control to /config endpoint
---
src/challenger/challenger-httpd_config.c | 53 ++++++++++++++++++++++++++------
1 file changed, 44 insertions(+), 9 deletions(-)
diff --git a/src/challenger/challenger-httpd_config.c
b/src/challenger/challenger-httpd_config.c
index fcbaf15..da6533f 100644
--- a/src/challenger/challenger-httpd_config.c
+++ b/src/challenger/challenger-httpd_config.c
@@ -36,17 +36,52 @@ CH_handler_config (struct CH_HandlerContext *hc,
const char *upload_data,
size_t *upload_data_size)
{
+ static struct MHD_Response *response;
+ static struct GNUNET_TIME_Absolute a;
+
(void) upload_data;
(void) upload_data_size;
- return TALER_MHD_REPLY_JSON_PACK (
- hc->connection,
- MHD_HTTP_OK,
- GNUNET_JSON_pack_string ("implementation",
- "urn:net:taler:specs:challenger:c-reference"),
- GNUNET_JSON_pack_string ("name",
- "challenger"),
- GNUNET_JSON_pack_string ("version",
- "1:0:1"));
+ if ( (GNUNET_TIME_absolute_is_past (a)) &&
+ (NULL != response) )
+ {
+ MHD_destroy_response (response);
+ response = NULL;
+ }
+ if (NULL == response)
+ {
+ struct GNUNET_TIME_Timestamp km;
+ char dat[128];
+
+ a = GNUNET_TIME_relative_to_absolute (GNUNET_TIME_UNIT_DAYS);
+ /* Round up to next full day to ensure the expiration
+ time does not become a fingerprint! */
+ a = GNUNET_TIME_absolute_round_down (a,
+ GNUNET_TIME_UNIT_DAYS);
+ a = GNUNET_TIME_absolute_add (a,
+ GNUNET_TIME_UNIT_DAYS);
+ /* => /config response stays at most 48h in caches! */
+ km = GNUNET_TIME_absolute_to_timestamp (a);
+ TALER_MHD_get_date_string (km.abs_time,
+ dat);
+ response = TALER_MHD_MAKE_JSON_PACK (
+ GNUNET_JSON_pack_string ("implementation",
+ "urn:net:taler:specs:challenger:c-reference"),
+ GNUNET_JSON_pack_string ("name",
+ "challenger"),
+ GNUNET_JSON_pack_string ("version",
+ "1:1:1"));
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_EXPIRES,
+ dat));
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (response,
+ MHD_HTTP_HEADER_CACHE_CONTROL,
+ "public,max-age=21600")); /* 6h */
+ }
+ return MHD_queue_response (hc->connection,
+ MHD_HTTP_OK,
+ response);
}
--
To stop receiving notification emails like this one, please contact
gnunet@gnunet.org.
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [taler-challenger] branch master updated: add cache control to /config endpoint,
gnunet <=