[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] r36023 - in gnunet/src: gns identity include rest
From: |
gnunet |
Subject: |
[GNUnet-SVN] r36023 - in gnunet/src: gns identity include rest |
Date: |
Mon, 29 Jun 2015 16:49:10 +0200 |
Author: schanzen
Date: 2015-06-29 16:49:09 +0200 (Mon, 29 Jun 2015)
New Revision: 36023
Modified:
gnunet/src/gns/plugin_rest_gns.c
gnunet/src/identity/plugin_rest_identity.c
gnunet/src/include/gnunet_rest_plugin.h
gnunet/src/rest/gnunet-rest-server.c
Log:
- give control over CORS methods to plugin
Modified: gnunet/src/gns/plugin_rest_gns.c
===================================================================
--- gnunet/src/gns/plugin_rest_gns.c 2015-06-29 14:33:38 UTC (rev 36022)
+++ gnunet/src/gns/plugin_rest_gns.c 2015-06-29 14:49:09 UTC (rev 36023)
@@ -648,7 +648,6 @@
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 @@
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");
Modified: gnunet/src/identity/plugin_rest_identity.c
===================================================================
--- gnunet/src/identity/plugin_rest_identity.c 2015-06-29 14:33:38 UTC (rev
36022)
+++ gnunet/src/identity/plugin_rest_identity.c 2015-06-29 14:49:09 UTC (rev
36023)
@@ -55,6 +55,8 @@
const struct GNUNET_CONFIGURATION_Handle *cfg;
+static char* allow_methods;
+
struct EgoEntry
{
/**
@@ -652,7 +654,24 @@
}
+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 @@
{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 @@
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 @@
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");
Modified: gnunet/src/include/gnunet_rest_plugin.h
===================================================================
--- gnunet/src/include/gnunet_rest_plugin.h 2015-06-29 14:33:38 UTC (rev
36022)
+++ gnunet/src/include/gnunet_rest_plugin.h 2015-06-29 14:49:09 UTC (rev
36023)
@@ -59,11 +59,6 @@
char *name;
/**
- * Supported HTTP Methods
- */
- char *allow_methods;
-
- /**
* Function to process a REST call
*
* @param method the HTTP method called
Modified: gnunet/src/rest/gnunet-rest-server.c
===================================================================
--- gnunet/src/rest/gnunet-rest-server.c 2015-06-29 14:33:38 UTC (rev
36022)
+++ gnunet/src/rest/gnunet-rest-server.c 2015-06-29 14:49:09 UTC (rev
36023)
@@ -350,12 +350,6 @@
"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,
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [GNUnet-SVN] r36023 - in gnunet/src: gns identity include rest,
gnunet <=