aboutsummaryrefslogtreecommitdiff
path: root/src/rest
diff options
context:
space:
mode:
Diffstat (limited to 'src/rest')
-rw-r--r--src/rest/gnunet-rest-server.c39
-rw-r--r--src/rest/rest.conf2
2 files changed, 40 insertions, 1 deletions
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c
index b08aee389..c14b09819 100644
--- a/src/rest/gnunet-rest-server.c
+++ b/src/rest/gnunet-rest-server.c
@@ -201,6 +201,14 @@ cleanup_handle (struct MhdConnectionHandle *handle)
201 MHD_destroy_response (handle->response); 201 MHD_destroy_response (handle->response);
202 if (NULL != handle->data_handle) 202 if (NULL != handle->data_handle)
203 { 203 {
204
205 if (NULL != handle->data_handle->header_param_map)
206 {
207 GNUNET_CONTAINER_multihashmap_iterate (handle->data_handle->header_param_map,
208 &cleanup_url_map,
209 NULL);
210 GNUNET_CONTAINER_multihashmap_destroy (handle->data_handle->header_param_map);
211 }
204 if (NULL != handle->data_handle->url_param_map) 212 if (NULL != handle->data_handle->url_param_map)
205 { 213 {
206 GNUNET_CONTAINER_multihashmap_iterate (handle->data_handle->url_param_map, 214 GNUNET_CONTAINER_multihashmap_iterate (handle->data_handle->url_param_map,
@@ -213,6 +221,31 @@ cleanup_handle (struct MhdConnectionHandle *handle)
213 GNUNET_free (handle); 221 GNUNET_free (handle);
214} 222}
215 223
224static int
225header_iterator (void *cls,
226 enum MHD_ValueKind kind,
227 const char *key,
228 const char *value)
229{
230 struct GNUNET_REST_RequestHandle *handle = cls;
231 struct GNUNET_HashCode hkey;
232 char *val;
233
234 GNUNET_CRYPTO_hash (key, strlen (key), &hkey);
235 GNUNET_asprintf (&val, "%s", value);
236 if (GNUNET_OK !=
237 GNUNET_CONTAINER_multihashmap_put (handle->header_param_map,
238 &hkey,
239 val,
240 GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY))
241 {
242 GNUNET_log (GNUNET_ERROR_TYPE_ERROR,
243 "Could not load add header `%s'=%s\n",
244 key, value);
245 }
246 return MHD_YES;
247}
248
216 249
217static int 250static int
218url_iterator (void *cls, 251url_iterator (void *cls,
@@ -321,11 +354,17 @@ create_response (void *cls,
321 rest_conndata_handle->data_size = *upload_data_size; 354 rest_conndata_handle->data_size = *upload_data_size;
322 rest_conndata_handle->url_param_map = GNUNET_CONTAINER_multihashmap_create (16, 355 rest_conndata_handle->url_param_map = GNUNET_CONTAINER_multihashmap_create (16,
323 GNUNET_NO); 356 GNUNET_NO);
357 rest_conndata_handle->header_param_map = GNUNET_CONTAINER_multihashmap_create (16,
358 GNUNET_NO);
324 con_handle->data_handle = rest_conndata_handle; 359 con_handle->data_handle = rest_conndata_handle;
325 MHD_get_connection_values (con, 360 MHD_get_connection_values (con,
326 MHD_GET_ARGUMENT_KIND, 361 MHD_GET_ARGUMENT_KIND,
327 &url_iterator, 362 &url_iterator,
328 rest_conndata_handle); 363 rest_conndata_handle);
364 MHD_get_connection_values (con,
365 MHD_HEADER_KIND,
366 &header_iterator,
367 rest_conndata_handle);
329 con_handle->state = GN_REST_STATE_PROCESSING; 368 con_handle->state = GN_REST_STATE_PROCESSING;
330 con_handle->plugin->process_request (rest_conndata_handle, 369 con_handle->plugin->process_request (rest_conndata_handle,
331 &plugin_callback, 370 &plugin_callback,
diff --git a/src/rest/rest.conf b/src/rest/rest.conf
index b86e6c1a0..f74d772e8 100644
--- a/src/rest/rest.conf
+++ b/src/rest/rest.conf
@@ -3,4 +3,4 @@ UNIXPATH = $GNUNET_USER_RUNTIME_DIR/gnunet-service-rest.sock
3BINARY=gnunet-rest-server 3BINARY=gnunet-rest-server
4REST_PORT=7776 4REST_PORT=7776
5REST_ALLOW_HEADERS=Authorization,Accept,Content-Type 5REST_ALLOW_HEADERS=Authorization,Accept,Content-Type
6REST_ALLOW_ORIGIN=* 6REST_ALLOW_ORIGIN=http://localhost:8000