aboutsummaryrefslogtreecommitdiff
path: root/src/identity/plugin_rest_identity.c
diff options
context:
space:
mode:
authorPhil <phil.buschmann@tum.de>2018-07-25 16:59:08 +0200
committerPhil <phil.buschmann@tum.de>2018-07-25 16:59:08 +0200
commit9009fb0aa496cd72ff6f1ea3d20ac4a547055e1b (patch)
treedde1a437bdca9fe056667aaa2749d067dc4f6456 /src/identity/plugin_rest_identity.c
parent8b89bb8b02c8949f3c74ad0668107d184aaa3788 (diff)
downloadgnunet-9009fb0aa496cd72ff6f1ea3d20ac4a547055e1b.tar.gz
gnunet-9009fb0aa496cd72ff6f1ea3d20ac4a547055e1b.zip
-fix identity file
Diffstat (limited to 'src/identity/plugin_rest_identity.c')
-rw-r--r--src/identity/plugin_rest_identity.c59
1 files changed, 30 insertions, 29 deletions
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 8d525b950..f1d33b0f3 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -2,20 +2,18 @@
2 This file is part of GNUnet. 2 This file is part of GNUnet.
3 Copyright (C) 2012-2015 GNUnet e.V. 3 Copyright (C) 2012-2015 GNUnet e.V.
4 4
5 GNUnet is free software; you can redistribute it and/or modify 5 GNUnet is free software: you can redistribute it and/or modify it
6 it under the terms of the GNU General Public License as published 6 under the terms of the GNU Affero General Public License as published
7 by the Free Software Foundation; either version 3, or (at your 7 by the Free Software Foundation, either version 3 of the License,
8 option) any later version. 8 or (at your option) any later version.
9 9
10 GNUnet is distributed in the hope that it will be useful, but 10 GNUnet is distributed in the hope that it will be useful, but
11 WITHOUT ANY WARRANTY; without even the implied warranty of 11 WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 General Public License for more details. 13 Affero General Public License for more details.
14 14
15 You should have received a copy of the GNU General Public License 15 You should have received a copy of the GNU Affero General Public License
16 along with GNUnet; see the file COPYING. If not, write to the 16 along with this program. If not, see <http://www.gnu.org/licenses/>.
17 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
18 Boston, MA 02110-1301, USA.
19 */ 17 */
20/** 18/**
21 * @author Martin Schanzenbach 19 * @author Martin Schanzenbach
@@ -202,8 +200,9 @@ struct RequestHandle
202 * @param handle Handle to clean up 200 * @param handle Handle to clean up
203 */ 201 */
204static void 202static void
205cleanup_handle (struct RequestHandle *handle) 203cleanup_handle (void *cls)
206{ 204{
205 struct RequestHandle *handle = cls;
207 struct EgoEntry *ego_entry; 206 struct EgoEntry *ego_entry;
208 struct EgoEntry *ego_tmp; 207 struct EgoEntry *ego_tmp;
209 208
@@ -248,20 +247,22 @@ do_error (void *cls)
248{ 247{
249 struct RequestHandle *handle = cls; 248 struct RequestHandle *handle = cls;
250 struct MHD_Response *resp; 249 struct MHD_Response *resp;
251 char *json_error; 250 json_t *json_error = json_object();
251 char *response;
252 252
253 if (NULL == handle->emsg) 253 if (NULL == handle->emsg)
254 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_UNKNOWN); 254 handle->emsg = GNUNET_strdup(GNUNET_REST_ERROR_UNKNOWN);
255 255
256 GNUNET_asprintf (&json_error, "{\"error\": \"%s\"}", handle->emsg); 256 json_object_set_new(json_error,"error", json_string(handle->emsg));
257 257
258 if (0 == handle->response_code) 258 if (0 == handle->response_code)
259 handle->response_code = MHD_HTTP_OK; 259 handle->response_code = MHD_HTTP_OK;
260 260 response = json_dumps (json_error, 0);
261 resp = GNUNET_REST_create_response (json_error); 261 resp = GNUNET_REST_create_response (response);
262 handle->proc (handle->proc_cls, resp, handle->response_code); 262 handle->proc (handle->proc_cls, resp, handle->response_code);
263 cleanup_handle (handle); 263 json_decref(json_error);
264 GNUNET_free(json_error); 264 GNUNET_free(response);
265 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
265} 266}
266 267
267/** 268/**
@@ -306,7 +307,7 @@ ego_get_for_subsystem (void *cls, struct GNUNET_IDENTITY_Ego *ego, void **ctx,
306 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 307 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
307 GNUNET_free(result_str); 308 GNUNET_free(result_str);
308 GNUNET_free(public_key_string); 309 GNUNET_free(public_key_string);
309 cleanup_handle (handle); 310 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
310} 311}
311 312
312/** 313/**
@@ -420,7 +421,7 @@ ego_get (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
420 json_decref (json_root); 421 json_decref (json_root);
421 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 422 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
422 GNUNET_free(result_str); 423 GNUNET_free(result_str);
423 cleanup_handle (handle); 424 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
424} 425}
425 426
426/** 427/**
@@ -444,7 +445,7 @@ do_finished (void *cls, const char *emsg)
444 } 445 }
445 resp = GNUNET_REST_create_response (NULL); 446 resp = GNUNET_REST_create_response (NULL);
446 handle->proc (handle->proc_cls, resp, handle->response_code); 447 handle->proc (handle->proc_cls, resp, handle->response_code);
447 cleanup_handle (handle); 448 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
448} 449}
449 450
450/** 451/**
@@ -530,7 +531,7 @@ ego_edit (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
530 json_decref (data_js); 531 json_decref (data_js);
531 resp = GNUNET_REST_create_response (NULL); 532 resp = GNUNET_REST_create_response (NULL);
532 handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); 533 handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND);
533 cleanup_handle (handle); 534 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
534 return; 535 return;
535 } 536 }
536 //This is a rename 537 //This is a rename
@@ -555,7 +556,7 @@ ego_edit (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
555 json_decref (data_js); 556 json_decref (data_js);
556 resp = GNUNET_REST_create_response (NULL); 557 resp = GNUNET_REST_create_response (NULL);
557 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); 558 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
558 cleanup_handle (handle); 559 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
559 return; 560 return;
560 } 561 }
561 } 562 }
@@ -677,7 +678,7 @@ ego_create (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
677 json_decref (data_js); 678 json_decref (data_js);
678 resp = GNUNET_REST_create_response (NULL); 679 resp = GNUNET_REST_create_response (NULL);
679 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT); 680 handle->proc (handle->proc_cls, resp, MHD_HTTP_CONFLICT);
680 cleanup_handle (handle); 681 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
681 return; 682 return;
682 } 683 }
683 } 684 }
@@ -732,7 +733,7 @@ ego_delete (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
732 { 733 {
733 resp = GNUNET_REST_create_response (NULL); 734 resp = GNUNET_REST_create_response (NULL);
734 handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND); 735 handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND);
735 cleanup_handle (handle); 736 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
736 return; 737 return;
737 } 738 }
738 handle->response_code = MHD_HTTP_NO_CONTENT; 739 handle->response_code = MHD_HTTP_NO_CONTENT;
@@ -760,7 +761,7 @@ options_cont (struct GNUNET_REST_RequestHandle *con_handle, const char* url,
760 resp = GNUNET_REST_create_response (NULL); 761 resp = GNUNET_REST_create_response (NULL);
761 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods); 762 MHD_add_response_header (resp, "Access-Control-Allow-Methods", allow_methods);
762 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 763 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
763 cleanup_handle (handle); 764 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
764 return; 765 return;
765} 766}
766 767