rewrite error handling and subsystem PUT
authorPhil <phil.buschmann@tum.de>
Sat, 11 Aug 2018 23:46:11 +0000 (01:46 +0200)
committerPhil <phil.buschmann@tum.de>
Sat, 11 Aug 2018 23:46:11 +0000 (01:46 +0200)
src/identity/plugin_rest_identity.c

index 89f6e7f8b028a5bf8a5eb70ddde1230da6d00a98..9f1765a631bed2cca48be9b41361ef0d7812e6c6 100644 (file)
@@ -560,6 +560,7 @@ ego_get_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
 
   if (strlen (GNUNET_REST_API_NS_IDENTITY_PUBKEY) >= strlen (handle->url))
   {
+    handle->response_code = MHD_HTTP_NOT_FOUND;
     handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_PUBKEY);
     GNUNET_SCHEDULER_add_now (&do_error, handle);
     return;
@@ -598,6 +599,7 @@ ego_get_name (struct GNUNET_REST_RequestHandle *con_handle,
 
   if (strlen (GNUNET_REST_API_NS_IDENTITY_NAME) >= strlen (handle->url))
   {
+    handle->response_code = MHD_HTTP_NOT_FOUND;
     handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_MISSING_NAME);
     GNUNET_SCHEDULER_add_now (&do_error, handle);
     return;
@@ -1036,7 +1038,6 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
 {
   struct RequestHandle *handle = cls;
   struct EgoEntry *ego_entry;
-  struct MHD_Response *resp;
   char *keystring;
 
   keystring = NULL;
@@ -1053,9 +1054,9 @@ ego_delete_pubkey (struct GNUNET_REST_RequestHandle *con_handle,
 
   if (NULL == ego_entry)
   {
-    resp = GNUNET_REST_create_response (NULL);
-    handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND);
-    GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+    handle->response_code = MHD_HTTP_NOT_FOUND;
+    handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+    GNUNET_SCHEDULER_add_now (&do_error, handle);
     return;
   }
 
@@ -1081,7 +1082,6 @@ ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle,
 {
   struct RequestHandle *handle = cls;
   struct EgoEntry *ego_entry;
-  struct MHD_Response *resp;
   char *name;
 
   name = NULL;
@@ -1098,9 +1098,9 @@ ego_delete_name (struct GNUNET_REST_RequestHandle *con_handle,
 
   if (NULL == ego_entry)
   {
-    resp = GNUNET_REST_create_response (NULL);
-    handle->proc (handle->proc_cls, resp, MHD_HTTP_NOT_FOUND);
-    GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
+    handle->response_code = MHD_HTTP_NOT_FOUND;
+    handle->emsg = GNUNET_strdup(GNUNET_REST_IDENTITY_NOT_FOUND);
+    GNUNET_SCHEDULER_add_now (&do_error, handle);
     return;
   }