From: David Barksdale Date: Thu, 26 Jun 2014 23:49:06 +0000 (+0000) Subject: Fix hostlist server CORS headers X-Git-Tag: initial-import-from-subversion-38251~3553 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=2a81b2108659c69f218dcb629dd740e6308aa4e4;p=oweals%2Fgnunet.git Fix hostlist server CORS headers --- diff --git a/src/hostlist/gnunet-daemon-hostlist_server.c b/src/hostlist/gnunet-daemon-hostlist_server.c index df45cd516..9ab2b2642 100644 --- a/src/hostlist/gnunet-daemon-hostlist_server.c +++ b/src/hostlist/gnunet-daemon-hostlist_server.c @@ -121,6 +121,27 @@ struct HostSet static struct HostSet *builder; +/** + * Add headers to a request indicating that we allow Cross-Origin Resource + * Sharing. + * + * @param response response to add headers to + */ +static void +add_cors_headers (struct MHD_Response *response) +{ + MHD_add_response_header (response, + "Access-Control-Allow-Origin", + "*"); + MHD_add_response_header (response, + "Access-Control-Allow-Methods", + "GET, OPTIONS"); + MHD_add_response_header (response, + "Access-Control-Max-Age", + "86400"); +} + + /** * Function that assembles our response. */ @@ -135,6 +156,7 @@ finish_response () response = MHD_create_response_from_data (builder->size, builder->data, MHD_YES, MHD_NO); + add_cors_headers (response); if ((NULL == daemon_handle_v4) && (NULL == daemon_handle_v6)) { MHD_destroy_response (response); @@ -277,27 +299,6 @@ accept_policy_callback (void *cls, } -/** - * Add headers to a request indicating that we allow Cross-Origin Resource - * Sharing. - * - * @param response response to add headers to - */ -static void -add_cors_headers (struct MHD_Response *response) -{ - MHD_add_response_header (response, - "Access-Control-Allow-Origin", - "*"); - MHD_add_response_header (response, - "Access-Control-Allow-Methods", - "GET, OPTIONS"); - MHD_add_response_header (response, - "Access-Control-Max-Age", - "86400"); -} - - /** * Main request handler. *