summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/gns/plugin_rest_gns.c2
-rw-r--r--src/identity/plugin_rest_identity.c24
-rw-r--r--src/include/gnunet_rest_plugin.h5
-rw-r--r--src/rest/gnunet-rest-server.c6
4 files changed, 22 insertions, 15 deletions
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index 1a5ee9eea..d7fc31d4c 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -648,7 +648,6 @@ libgnunet_plugin_rest_gns_init (void *cls)
api->cls = &plugin;
api->name = API_NAMESPACE;
api->process_request = &rest_gns_process_request;
- GNUNET_asprintf (&api->allow_methods, "%s", MHD_HTTP_METHOD_GET);
GNUNET_log (GNUNET_ERROR_TYPE_INFO,
_("GNS REST API initialized\n"));
return api;
@@ -668,7 +667,6 @@ libgnunet_plugin_rest_gns_done (void *cls)
struct Plugin *plugin = api->cls;
plugin->cfg = NULL;
- GNUNET_free_non_null (api->allow_methods);
GNUNET_free (api);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"GNS REST plugin is finished\n");
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 8a2c24d1f..70ede69eb 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -55,6 +55,8 @@ struct Plugin
const struct GNUNET_CONFIGURATION_Handle *cfg;
+static char* allow_methods;
+
struct EgoEntry
{
/**
@@ -652,6 +654,23 @@ ego_delete_cont (struct RestConnectionDataHandle *con_handle,
}
+void
+options_cont (struct RestConnectionDataHandle *con_handle,
+ const char* url,
+ void *cls)
+{
+ struct MHD_Response *resp;
+ struct RequestHandle *handle = cls;
+
+ //For now, independent of path return all options
+ resp = GNUNET_REST_create_json_response (NULL);
+ MHD_add_response_header (resp,
+ "Access-Control-Allow-Methods",
+ allow_methods);
+ handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
+ cleanup_handle (handle);
+ return;
+}
/**
* Handle rest request
@@ -666,6 +685,7 @@ init_cont (struct RequestHandle *handle)
{MHD_HTTP_METHOD_POST, GNUNET_REST_API_NS_IDENTITY, &ego_create_cont},
{MHD_HTTP_METHOD_PUT, GNUNET_REST_API_NS_IDENTITY, &ego_edit_cont},
{MHD_HTTP_METHOD_DELETE, GNUNET_REST_API_NS_IDENTITY, &ego_delete_cont},
+ {MHD_HTTP_METHOD_OPTIONS, GNUNET_REST_API_NS_IDENTITY, &options_cont},
GNUNET_REST_HANDLER_END
};
@@ -799,7 +819,7 @@ libgnunet_plugin_rest_identity_init (void *cls)
api->cls = &plugin;
api->name = GNUNET_REST_API_NS_IDENTITY;
api->process_request = &rest_identity_process_request;
- GNUNET_asprintf (&api->allow_methods,
+ GNUNET_asprintf (&allow_methods,
"%s, %s, %s, %s, %s",
MHD_HTTP_METHOD_GET,
MHD_HTTP_METHOD_POST,
@@ -826,7 +846,7 @@ libgnunet_plugin_rest_identity_done (void *cls)
struct Plugin *plugin = api->cls;
plugin->cfg = NULL;
- GNUNET_free_non_null (api->allow_methods);
+ GNUNET_free_non_null (allow_methods);
GNUNET_free (api);
GNUNET_log (GNUNET_ERROR_TYPE_DEBUG,
"Identity REST plugin is finished\n");
diff --git a/src/include/gnunet_rest_plugin.h b/src/include/gnunet_rest_plugin.h
index abc0aea4c..e1eabd813 100644
--- a/src/include/gnunet_rest_plugin.h
+++ b/src/include/gnunet_rest_plugin.h
@@ -59,11 +59,6 @@ struct GNUNET_REST_Plugin
char *name;
/**
- * Supported HTTP Methods
- */
- char *allow_methods;
-
- /**
* Function to process a REST call
*
* @param method the HTTP method called
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index 3ce177e9c..9aa6fa40e 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -350,12 +350,6 @@ create_response (void *cls,
"Access-Control-Allow-Headers",
allow_headers);
}
- if (NULL != con_handle->plugin)
- {
- MHD_add_response_header (con_handle->response,
- "Access-Control-Allow-Methods",
- con_handle->plugin->allow_methods);
- }
}
int ret = MHD_queue_response (con,
con_handle->status,