diff options
author | Phil <phil.buschmann@tum.de> | 2018-01-22 17:38:45 +0100 |
---|---|---|
committer | Phil <phil.buschmann@tum.de> | 2018-01-22 17:38:45 +0100 |
commit | 8c785ca6cea5c84d84fb900a8f519a4d87a3fe8c (patch) | |
tree | 0ef829a4b12ba2e11b337d0136c7be8471d09e6e /src/rest | |
parent | 963b0f5a783004823a14f65c697cd83dbfb60463 (diff) | |
parent | 4fce9ab87811196126dc64afa905cb72688728ea (diff) | |
download | gnunet-8c785ca6cea5c84d84fb900a8f519a4d87a3fe8c.tar.gz gnunet-8c785ca6cea5c84d84fb900a8f519a4d87a3fe8c.zip |
Merge branch 'master' into identity_oidc
Diffstat (limited to 'src/rest')
-rw-r--r-- | src/rest/gnunet-rest-server.c | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/src/rest/gnunet-rest-server.c b/src/rest/gnunet-rest-server.c index c14b09819..a67b3203a 100644 --- a/src/rest/gnunet-rest-server.c +++ b/src/rest/gnunet-rest-server.c | |||
@@ -131,6 +131,8 @@ struct MhdConnectionHandle | |||
131 | 131 | ||
132 | struct GNUNET_REST_RequestHandle *data_handle; | 132 | struct GNUNET_REST_RequestHandle *data_handle; |
133 | 133 | ||
134 | struct MHD_PostProcessor *pp; | ||
135 | |||
134 | int status; | 136 | int status; |
135 | 137 | ||
136 | int state; | 138 | int state; |
@@ -272,6 +274,40 @@ url_iterator (void *cls, | |||
272 | return MHD_YES; | 274 | return MHD_YES; |
273 | } | 275 | } |
274 | 276 | ||
277 | static int | ||
278 | post_data_iter (void *cls, | ||
279 | enum MHD_ValueKind kind, | ||
280 | const char *key, | ||
281 | const char *filename, | ||
282 | const char *content_type, | ||
283 | const char *transfer_encoding, | ||
284 | const char *data, | ||
285 | uint64_t off, | ||
286 | size_t size) | ||
287 | { | ||
288 | struct GNUNET_REST_RequestHandle *handle = cls; | ||
289 | struct GNUNET_HashCode hkey; | ||
290 | char *val; | ||
291 | |||
292 | if (MHD_POSTDATA_KIND != kind) | ||
293 | return MHD_YES; | ||
294 | |||
295 | GNUNET_CRYPTO_hash (key, strlen (key), &hkey); | ||
296 | GNUNET_asprintf (&val, "%s", data); | ||
297 | if (GNUNET_OK != | ||
298 | GNUNET_CONTAINER_multihashmap_put (handle->url_param_map, | ||
299 | &hkey, | ||
300 | val, | ||
301 | GNUNET_CONTAINER_MULTIHASHMAPOPTION_UNIQUE_ONLY)) | ||
302 | { | ||
303 | GNUNET_log (GNUNET_ERROR_TYPE_ERROR, | ||
304 | "Could not load add url param `%s'=%s\n", | ||
305 | key, data); | ||
306 | } | ||
307 | return MHD_YES; | ||
308 | |||
309 | } | ||
310 | |||
275 | /* ********************************* MHD response generation ******************* */ | 311 | /* ********************************* MHD response generation ******************* */ |
276 | 312 | ||
277 | /** | 313 | /** |
@@ -343,6 +379,7 @@ create_response (void *cls, | |||
343 | MHD_HTTP_NOT_FOUND, | 379 | MHD_HTTP_NOT_FOUND, |
344 | failure_response); | 380 | failure_response); |
345 | } | 381 | } |
382 | |||
346 | return MHD_YES; | 383 | return MHD_YES; |
347 | } | 384 | } |
348 | if (GN_REST_STATE_INIT == con_handle->state) | 385 | if (GN_REST_STATE_INIT == con_handle->state) |
@@ -361,10 +398,25 @@ create_response (void *cls, | |||
361 | MHD_GET_ARGUMENT_KIND, | 398 | MHD_GET_ARGUMENT_KIND, |
362 | &url_iterator, | 399 | &url_iterator, |
363 | rest_conndata_handle); | 400 | rest_conndata_handle); |
401 | <<<<<<< HEAD | ||
364 | MHD_get_connection_values (con, | 402 | MHD_get_connection_values (con, |
365 | MHD_HEADER_KIND, | 403 | MHD_HEADER_KIND, |
366 | &header_iterator, | 404 | &header_iterator, |
367 | rest_conndata_handle); | 405 | rest_conndata_handle); |
406 | ======= | ||
407 | con_handle->pp = MHD_create_post_processor(con, | ||
408 | 4000, | ||
409 | post_data_iter, | ||
410 | rest_conndata_handle); | ||
411 | if (*upload_data_size) | ||
412 | { | ||
413 | MHD_post_process(con_handle->pp, upload_data, *upload_data_size); | ||
414 | } | ||
415 | else | ||
416 | { | ||
417 | MHD_destroy_post_processor(con_handle->pp); | ||
418 | } | ||
419 | >>>>>>> master | ||
368 | con_handle->state = GN_REST_STATE_PROCESSING; | 420 | con_handle->state = GN_REST_STATE_PROCESSING; |
369 | con_handle->plugin->process_request (rest_conndata_handle, | 421 | con_handle->plugin->process_request (rest_conndata_handle, |
370 | &plugin_callback, | 422 | &plugin_callback, |