aboutsummaryrefslogtreecommitdiff
path: root/src/hostlist
diff options
context:
space:
mode:
authorDavid Barksdale <amatus.amongus@gmail.com>2014-06-26 23:49:06 +0000
committerDavid Barksdale <amatus.amongus@gmail.com>2014-06-26 23:49:06 +0000
commit2a81b2108659c69f218dcb629dd740e6308aa4e4 (patch)
tree8bf238ad9270611f1804556e7458a7a0a323732e /src/hostlist
parentf5c4fff8b1ae75229860031921ef3faaf88b80dc (diff)
downloadgnunet-2a81b2108659c69f218dcb629dd740e6308aa4e4.tar.gz
gnunet-2a81b2108659c69f218dcb629dd740e6308aa4e4.zip
Fix hostlist server CORS headers
Diffstat (limited to 'src/hostlist')
-rw-r--r--src/hostlist/gnunet-daemon-hostlist_server.c43
1 files changed, 22 insertions, 21 deletions
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
@@ -122,6 +122,27 @@ static struct HostSet *builder;
122 122
123 123
124/** 124/**
125 * Add headers to a request indicating that we allow Cross-Origin Resource
126 * Sharing.
127 *
128 * @param response response to add headers to
129 */
130static void
131add_cors_headers (struct MHD_Response *response)
132{
133 MHD_add_response_header (response,
134 "Access-Control-Allow-Origin",
135 "*");
136 MHD_add_response_header (response,
137 "Access-Control-Allow-Methods",
138 "GET, OPTIONS");
139 MHD_add_response_header (response,
140 "Access-Control-Max-Age",
141 "86400");
142}
143
144
145/**
125 * Function that assembles our response. 146 * Function that assembles our response.
126 */ 147 */
127static void 148static void
@@ -135,6 +156,7 @@ finish_response ()
135 response = 156 response =
136 MHD_create_response_from_data (builder->size, builder->data, MHD_YES, 157 MHD_create_response_from_data (builder->size, builder->data, MHD_YES,
137 MHD_NO); 158 MHD_NO);
159 add_cors_headers (response);
138 if ((NULL == daemon_handle_v4) && (NULL == daemon_handle_v6)) 160 if ((NULL == daemon_handle_v4) && (NULL == daemon_handle_v6))
139 { 161 {
140 MHD_destroy_response (response); 162 MHD_destroy_response (response);
@@ -278,27 +300,6 @@ accept_policy_callback (void *cls,
278 300
279 301
280/** 302/**
281 * Add headers to a request indicating that we allow Cross-Origin Resource
282 * Sharing.
283 *
284 * @param response response to add headers to
285 */
286static void
287add_cors_headers (struct MHD_Response *response)
288{
289 MHD_add_response_header (response,
290 "Access-Control-Allow-Origin",
291 "*");
292 MHD_add_response_header (response,
293 "Access-Control-Allow-Methods",
294 "GET, OPTIONS");
295 MHD_add_response_header (response,
296 "Access-Control-Max-Age",
297 "86400");
298}
299
300
301/**
302 * Main request handler. 303 * Main request handler.
303 * 304 *
304 * @param cls argument given together with the function 305 * @param cls argument given together with the function