From ac923e939b6acf141f7ca101b41a18bae9e54d83 Mon Sep 17 00:00:00 2001 From: Christian Grothoff Date: Fri, 17 Jan 2020 00:20:57 +0100 Subject: fix #6031 --- src/sync/sync-httpd.c | 48 ++++++++++++++++++++++++++++++------------------ 1 file changed, 30 insertions(+), 18 deletions(-) diff --git a/src/sync/sync-httpd.c b/src/sync/sync-httpd.c index 14b2470..7b9587b 100644 --- a/src/sync/sync-httpd.c +++ b/src/sync/sync-httpd.c @@ -240,6 +240,11 @@ url_handler (void *cls, upload_data, upload_data_size); } + if (0 == strcasecmp (method, + MHD_HTTP_METHOD_OPTIONS)) + { + return TALER_MHD_reply_cors_preflight (connection); + } if (0 == strcasecmp (method, MHD_HTTP_METHOD_GET)) { @@ -270,27 +275,34 @@ url_handler (void *cls, { struct SH_RequestHandler *rh = &handlers[i]; - if ( (0 == strcmp (url, - rh->url)) && - ( (NULL == rh->method) || - (0 == strcasecmp (method, - rh->method)) ) ) + if (0 == strcmp (url, + rh->url)) { - int ret; - - ret = rh->handler (rh, - connection, - con_cls, - upload_data, - upload_data_size); - hc = *con_cls; - if (NULL != hc) + if (0 == strcasecmp (method, + MHD_HTTP_METHOD_OPTIONS)) { - /* Store the async context ID, so we can restore it if - * we get another callack for this request. */ - hc->async_scope_id = aid; + return TALER_MHD_reply_cors_preflight (connection); + } + if ( (NULL == rh->method) || + (0 == strcasecmp (method, + rh->method)) ) + { + int ret; + + ret = rh->handler (rh, + connection, + con_cls, + upload_data, + upload_data_size); + hc = *con_cls; + if (NULL != hc) + { + /* Store the async context ID, so we can restore it if + * we get another callack for this request. */ + hc->async_scope_id = aid; + } + return ret; } - return ret; } } return SH_MHD_handler_static_response (&h404, -- cgit v1.2.3