Fix hostlist server CORS headers
authorDavid Barksdale <amatus.amongus@gmail.com>
Thu, 26 Jun 2014 23:49:06 +0000 (23:49 +0000)
committerDavid Barksdale <amatus.amongus@gmail.com>
Thu, 26 Jun 2014 23:49:06 +0000 (23:49 +0000)
src/hostlist/gnunet-daemon-hostlist_server.c

index df45cd516bfb285f02e15f6144b742a04ef2b51d..9ab2b2642a3a70ad6e4cc71e877c67c50b3a4e49 100644 (file)
@@ -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.
  *