summaryrefslogtreecommitdiff
path: root/src/mhd
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2020-01-15 15:52:12 +0100
committerFlorian Dold <florian.dold@gmail.com>2020-01-15 15:52:23 +0100
commit3b13aaf844f3b61950f437cb339fb881312ecf7b (patch)
treee9e174a171897025a8b08a9deef18b94e84dd765 /src/mhd
parent19d9369ff6df2e4bfd896cce5fcb2ae679402bc0 (diff)
downloadexchange-3b13aaf844f3b61950f437cb339fb881312ecf7b.tar.gz
exchange-3b13aaf844f3b61950f437cb339fb881312ecf7b.tar.bz2
exchange-3b13aaf844f3b61950f437cb339fb881312ecf7b.zip
respond with CORS headers for OPTIONS pre-flight request
Diffstat (limited to 'src/mhd')
-rw-r--r--src/mhd/mhd_responses.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/mhd/mhd_responses.c b/src/mhd/mhd_responses.c
index a8c15930..d26f533e 100644
--- a/src/mhd/mhd_responses.c
+++ b/src/mhd/mhd_responses.c
@@ -268,6 +268,29 @@ TALER_MHD_reply_json (struct MHD_Connection *connection,
/**
+ * Send back a "204 No Content" response with headers
+ * for the CORS pre-flight request.
+ *
+ * @param connection the MHD connection
+ * @return MHD result code
+ */
+int
+TALER_MHD_reply_cors_preflight (struct MHD_Connection *connection)
+{
+ struct MHD_Response *resp;
+
+ GNUNET_assert (NULL != (resp = MHD_create_response_from_buffer (0, NULL,
+ MHD_RESPMEM_PERSISTENT)));
+ /* This adds the Access-Control-Allow-Origin header.
+ * All endpoints of the exchange allow CORS. */
+ TALER_MHD_add_global_headers (resp);
+ GNUNET_assert (MHD_YES == MHD_queue_response (connection, MHD_HTTP_NO_CONTENT,
+ resp));
+ return MHD_YES;
+}
+
+
+/**
* Function to call to handle the request by building a JSON
* reply from a format string and varargs.
*