summaryrefslogtreecommitdiff
path: root/src/exchange
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/exchange
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/exchange')
-rw-r--r--src/exchange/taler-exchange-httpd.c19
1 files changed, 14 insertions, 5 deletions
diff --git a/src/exchange/taler-exchange-httpd.c b/src/exchange/taler-exchange-httpd.c
index e53c04d98..b2c9e4d84 100644
--- a/src/exchange/taler-exchange-httpd.c
+++ b/src/exchange/taler-exchange-httpd.c
@@ -420,11 +420,20 @@ handle_mhd_request (void *cls,
for (unsigned int i = 0; NULL != handlers[i].url; i++)
{
rh = &handlers[i];
- if ( (0 == strcmp (url,
- rh->url)) &&
- ( (NULL == rh->method) ||
- (0 == strcmp (method,
- rh->method)) ) )
+ if (0 != strcmp (url, rh->url))
+ continue;
+
+ /* The URL is a match! What we now do depends on the method. */
+
+ if (0 == strcmp (method, MHD_HTTP_METHOD_OPTIONS))
+ {
+ GNUNET_async_scope_restore (&old_scope);
+ return TALER_MHD_reply_cors_preflight (connection);
+ }
+
+ if ( (NULL == rh->method) ||
+ (0 == strcmp (method,
+ rh->method)) )
{
/* FIXME: consider caching 'rh' in '**connection_cls' to
avoid repeated lookup! */