diff options
author | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2017-12-11 13:01:03 +0100 |
---|---|---|
committer | Schanzenbach, Martin <martin.schanzenbach@aisec.fraunhofer.de> | 2017-12-11 13:01:03 +0100 |
commit | 5da3c7cf721ee3f6fe6efe515b39e4a370650366 (patch) | |
tree | c717d543445ad57ffe152f50ec8a3db3e99160bc /src/rest | |
parent | 3fdb794b668a634824072f57aac27368e9366e16 (diff) | |
download | gnunet-5da3c7cf721ee3f6fe6efe515b39e4a370650366.tar.gz gnunet-5da3c7cf721ee3f6fe6efe515b39e4a370650366.zip |
-add header map to rest handle
Diffstat (limited to 'src/rest')
-rw-r--r-- | src/rest/gnunet-rest-server.c | 31 |
1 files changed, 31 insertions, 0 deletions
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) | |||
210 | GNUNET_free (handle); | 210 | GNUNET_free (handle); |
211 | } | 211 | } |
212 | 212 | ||
213 | static int | ||
214 | header_iterator (void *cls, | ||
215 | enum MHD_ValueKind kind, | ||
216 | const char *key, | ||
217 | const char *value) | ||
218 | { | ||
219 | struct GNUNET_REST_RequestHandle *handle = cls; | ||
220 | struct GNUNET_HashCode hkey; | ||
221 | char *val; | ||
222 | |||
223 | GNUNET_CRYPTO_hash (key, strlen (key), &hkey); | ||
224 | GNUNET_asprintf (&val, "%s", value); | ||
225 | if (GNUNET_OK != | ||
226 | GNUNET_CONTAINER_multihashmap_put (handle->header_param_map, | ||
227 | &hkey, | ||
228 | val, | ||
229 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
230 | { | ||
231 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
232 | "Could not load add header `%s'=%s\n", | ||
233 | key, value); | ||
234 | } | ||
235 | return MHD_YES; | ||
236 | } | ||
237 | |||
213 | 238 | ||
214 | static int | 239 | static int |
215 | url_iterator (void *cls, | 240 | url_iterator (void *cls, |
@@ -318,11 +343,17 @@ create_response (void *cls, | |||
318 | rest_conndata_handle->data_size = *upload_data_size; | 343 | rest_conndata_handle->data_size = *upload_data_size; |
319 | rest_conndata_handle->url_param_map = GNUNET_CONTAINER_multihashmap_create (16, | 344 | rest_conndata_handle->url_param_map = GNUNET_CONTAINER_multihashmap_create (16, |
320 | GNUNET_NO); | 345 | GNUNET_NO); |
346 | rest_conndata_handle->header_param_map = GNUNET_CONTAINER_multihashmap_create (16, | ||
347 | GNUNET_NO); | ||
321 | con_handle->data_handle = rest_conndata_handle; | 348 | con_handle->data_handle = rest_conndata_handle; |
322 | MHD_get_connection_values (con, | 349 | MHD_get_connection_values (con, |
323 | MHD_GET_ARGUMENT_KIND, | 350 | MHD_GET_ARGUMENT_KIND, |
324 | &url_iterator, | 351 | &url_iterator, |
325 | rest_conndata_handle); | 352 | rest_conndata_handle); |
353 | MHD_get_connection_values (con, | ||
354 | MHD_HEADER_KIND, | ||
355 | &header_iterator, | ||
356 | rest_conndata_handle); | ||
326 | con_handle->state = GN_REST_STATE_PROCESSING; | 357 | con_handle->state = GN_REST_STATE_PROCESSING; |
327 | con_handle->plugin->process_request (rest_conndata_handle, | 358 | con_handle->plugin->process_request (rest_conndata_handle, |
328 | &plugin_callback, | 359 | &plugin_callback, |