[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[GNUnet-SVN] [gnunet] 14/45: -add header map to rest handle
From: |
gnunet |
Subject: |
[GNUnet-SVN] [gnunet] 14/45: -add header map to rest handle |
Date: |
Sun, 25 Feb 2018 16:25:18 +0100 |
This is an automated email from the git hooks/post-receive script.
martin-schanzenbach pushed a commit to branch master
in repository gnunet.
commit 5da3c7cf721ee3f6fe6efe515b39e4a370650366
Author: Schanzenbach, Martin <address@hidden>
AuthorDate: Mon Dec 11 13:01:03 2017 +0100
-add header map to rest handle
---
src/include/gnunet_rest_lib.h | 24 ++++++++++++++++++++++++
src/rest/gnunet-rest-server.c | 31 +++++++++++++++++++++++++++++++
2 files changed, 55 insertions(+)
diff --git a/src/include/gnunet_rest_lib.h b/src/include/gnunet_rest_lib.h
index 243c38403..5bf04636b 100644
--- a/src/include/gnunet_rest_lib.h
+++ b/src/include/gnunet_rest_lib.h
@@ -38,10 +38,34 @@
struct GNUNET_REST_RequestHandle
{
+ /**
+ * Map of url parameters
+ */
struct GNUNET_CONTAINER_MultiHashMap *url_param_map;
+
+ /**
+ * Map of headers
+ */
+ struct GNUNET_CONTAINER_MultiHashMap *header_param_map;
+
+ /**
+ * The HTTP method as MHD value (see microhttpd.h)
+ */
const char *method;
+
+ /**
+ * The url as string
+ */
const char *url;
+
+ /**
+ * The POST data
+ */
const char *data;
+
+ /**
+ * The POST data size
+ */
size_t data_size;
};
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index 5b92c6c43..cb903e388 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -210,6 +210,31 @@ cleanup_handle (struct MhdConnectionHandle *handle)
GNUNET_free (handle);
}
+static int
+header_iterator (void *cls,
+ enum MHD_ValueKind kind,
+ const char *key,
+ const char *value)
+{
+ struct GNUNET_REST_RequestHandle *handle = cls;
+ struct GNUNET_HashCode hkey;
+ char *val;
+
+ GNUNET_CRYPTO_hash (key, strlen (key), &hkey);
+ GNUNET_asprintf (&val, "%s", value);
+ if (GNUNET_OK !=
+ GNUNET_CONTAINER_multihashmap_put (handle->header_param_map,
+ &hkey,
+ val,
+
GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
+ {
+ GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
+ "Could not load add header `%s'=%s\n",
+ key, value);
+ }
+ return MHD_YES;
+}
+
static int
url_iterator (void *cls,
@@ -318,11 +343,17 @@ create_response (void *cls,
rest_conndata_handle->data_size = *upload_data_size;
rest_conndata_handle->url_param_map = GNUNET_CONTAINER_multihashmap_create
(16,
GNUNET_NO);
+ rest_conndata_handle->header_param_map =
GNUNET_CONTAINER_multihashmap_create (16,
+
GNUNET_NO);
con_handle->data_handle = rest_conndata_handle;
MHD_get_connection_values (con,
MHD_GET_ARGUMENT_KIND,
&url_iterator,
rest_conndata_handle);
+ MHD_get_connection_values (con,
+ MHD_HEADER_KIND,
+ &header_iterator,
+ rest_conndata_handle);
con_handle->state = GN_REST_STATE_PROCESSING;
con_handle->plugin->process_request (rest_conndata_handle,
&plugin_callback,
--
To stop receiving notification emails like this one, please contact
address@hidden
- [GNUnet-SVN] [gnunet] 05/45: -commit broken, (continued)
- [GNUnet-SVN] [gnunet] 05/45: -commit broken, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 07/45: Merge branch 'identity_abe' into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 03/45: Merge branch 'identity_abe' into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 02/45: Merge remote-tracking branch 'origin/identity_abe' into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 10/45: -merge, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 17/45: -fix, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 13/45: -merge, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 09/45: Merge branch 'identity_oidc' of git-int.aisec.fraunhofer.de:sas/gnunet-mirror into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 12/45: -fixed nonce=(null), gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 16/45: -merge branch 'identity_oidc' of git-int.aisec.fraunhofer.de:sas/gnunet-mirror into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 14/45: -add header map to rest handle,
gnunet <=
- [GNUnet-SVN] [gnunet] 21/45: -merge, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 18/45: -merge branch 'identity_oidc' of git-int.aisec.fraunhofer.de:sas/gnunet-mirror into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 08/45: --commit still broken, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 11/45: Refactored file, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 27/45: Merge remote-tracking branch 'gnunet/master' into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 38/45: -fix unsafed file, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 22/45: -add todos; cleanup, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 24/45: Merge remote-tracking branch 'origin/master' into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 39/45: -Merge branch 'master' into identity_oidc, gnunet, 2018/02/25
- [GNUnet-SVN] [gnunet] 20/45: -minor, gnunet, 2018/02/25