summaryrefslogtreecommitdiff
path: root/src/mhd/mhd_responses.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mhd/mhd_responses.c')
-rw-r--r--src/mhd/mhd_responses.c79
1 files changed, 56 insertions, 23 deletions
diff --git a/src/mhd/mhd_responses.c b/src/mhd/mhd_responses.c
index c993436cd..7dd6824e2 100644
--- a/src/mhd/mhd_responses.c
+++ b/src/mhd/mhd_responses.c
@@ -53,6 +53,11 @@ TALER_MHD_add_global_headers (struct MHD_Response *response)
MHD_add_response_header (response,
MHD_HTTP_HEADER_ACCESS_CONTROL_ALLOW_ORIGIN,
"*"));
+ GNUNET_break (MHD_YES ==
+ MHD_add_response_header (response,
+ /* Not available as MHD constant yet */
+ "Access-Control-Expose-Headers",
+ "*"));
}
@@ -268,7 +273,6 @@ TALER_MHD_reply_cors_preflight (struct MHD_Connection *connection)
/* Not available as MHD constant yet */
"Access-Control-Allow-Methods",
"*"));
-
{
MHD_RESULT ret;
@@ -367,8 +371,7 @@ TALER_MHD_make_error (enum TALER_ErrorCode ec,
const char *detail)
{
return TALER_MHD_MAKE_JSON_PACK (
- GNUNET_JSON_pack_uint64 ("code", ec),
- GNUNET_JSON_pack_string ("hint", TALER_ErrorCode_get_hint (ec)),
+ TALER_MHD_PACK_EC (ec),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_string ("detail", detail)));
}
@@ -383,8 +386,7 @@ TALER_MHD_reply_with_error (struct MHD_Connection *connection,
return TALER_MHD_REPLY_JSON_PACK (
connection,
http_status,
- GNUNET_JSON_pack_uint64 ("code", ec),
- GNUNET_JSON_pack_string ("hint", TALER_ErrorCode_get_hint (ec)),
+ TALER_MHD_PACK_EC (ec),
GNUNET_JSON_pack_allow_null (
GNUNET_JSON_pack_string ("detail", detail)));
}
@@ -415,24 +417,10 @@ TALER_MHD_reply_with_ec (struct MHD_Connection *connection,
MHD_RESULT
TALER_MHD_reply_request_too_large (struct MHD_Connection *connection)
{
- struct MHD_Response *response;
-
- response = MHD_create_response_from_buffer (0,
- NULL,
- MHD_RESPMEM_PERSISTENT);
- if (NULL == response)
- return MHD_NO;
- TALER_MHD_add_global_headers (response);
-
- {
- MHD_RESULT ret;
-
- ret = MHD_queue_response (connection,
- MHD_HTTP_REQUEST_ENTITY_TOO_LARGE,
- response);
- MHD_destroy_response (response);
- return ret;
- }
+ return TALER_MHD_reply_with_error (connection,
+ MHD_HTTP_REQUEST_ENTITY_TOO_LARGE,
+ TALER_EC_GENERIC_UPLOAD_EXCEEDS_LIMIT,
+ NULL);
}
@@ -514,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 */