summaryrefslogtreecommitdiff
path: root/src/mhd
diff options
context:
space:
mode:
authorChristian Grothoff <christian@grothoff.org>2022-05-12 14:15:02 +0200
committerChristian Grothoff <christian@grothoff.org>2022-05-12 14:15:02 +0200
commit75d9584e280ebfb3fcb400f46942695ac6e2958e (patch)
treeafe300a9dcd4aea77ae8612ef4777ffc896cae18 /src/mhd
parent6cf4a068ad58f22d1896d322fc96b59d1120a98c (diff)
downloadexchange-75d9584e280ebfb3fcb400f46942695ac6e2958e.tar.gz
exchange-75d9584e280ebfb3fcb400f46942695ac6e2958e.tar.bz2
exchange-75d9584e280ebfb3fcb400f46942695ac6e2958e.zip
add Etag and 'expires' to /wire
Diffstat (limited to 'src/mhd')
-rw-r--r--src/mhd/mhd_legal.c4
-rw-r--r--src/mhd/mhd_responses.c45
2 files changed, 47 insertions, 2 deletions
diff --git a/src/mhd/mhd_legal.c b/src/mhd/mhd_legal.c
index 64c176a93..bd596862c 100644
--- a/src/mhd/mhd_legal.c
+++ b/src/mhd/mhd_legal.c
@@ -178,8 +178,8 @@ TALER_MHD_reply_legal (struct MHD_Connection *conn,
a = GNUNET_TIME_relative_to_absolute (MAX_TERMS_CACHING);
m = GNUNET_TIME_absolute_to_timestamp (a);
- get_date_string (m.abs_time,
- dat);
+ TALER_MHD_get_date_string (m.abs_time,
+ dat);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
"Setting 'Expires' header to '%s'\n",
dat);
diff --git a/src/mhd/mhd_responses.c b/src/mhd/mhd_responses.c
index a639f4052..7dd6824e2 100644
--- a/src/mhd/mhd_responses.c
+++ b/src/mhd/mhd_responses.c
@@ -502,4 +502,49 @@ TALER_MHD_reply_static (struct MHD_Connection *connection,
}
+void
+TALER_MHD_get_date_string (struct GNUNET_TIME_Absolute at,
+ char date[128])
+{
+ static const char *const days[] =
+ { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
+ static const char *const mons[] =
+ { "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct",
+ "Nov", "Dec"};
+ struct tm now;
+ time_t t;
+#if ! defined(HAVE_C11_GMTIME_S) && ! defined(HAVE_W32_GMTIME_S) && \
+ ! defined(HAVE_GMTIME_R)
+ struct tm*pNow;
+#endif
+
+ date[0] = 0;
+ t = (time_t) (at.abs_value_us / 1000LL / 1000LL);
+#if defined(HAVE_C11_GMTIME_S)
+ if (NULL == gmtime_s (&t, &now))
+ return;
+#elif defined(HAVE_W32_GMTIME_S)
+ if (0 != gmtime_s (&now, &t))
+ return;
+#elif defined(HAVE_GMTIME_R)
+ if (NULL == gmtime_r (&t, &now))
+ return;
+#else
+ pNow = gmtime (&t);
+ if (NULL == pNow)
+ return;
+ now = *pNow;
+#endif
+ sprintf (date,
+ "%3s, %02u %3s %04u %02u:%02u:%02u GMT",
+ days[now.tm_wday % 7],
+ (unsigned int) now.tm_mday,
+ mons[now.tm_mon % 12],
+ (unsigned int) (1900 + now.tm_year),
+ (unsigned int) now.tm_hour,
+ (unsigned int) now.tm_min,
+ (unsigned int) now.tm_sec);
+}
+
+
/* end of mhd_responses.c */