aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSchanzenbach, Martin <mschanzenbach@posteo.de>2020-05-09 20:55:08 +0200
committerSchanzenbach, Martin <mschanzenbach@posteo.de>2020-05-09 20:55:08 +0200
commit63c92bbef932b831de7741ecc45c21915bfda82a (patch)
tree9de65a8bfc8e86215e29d0b09f6546b3f1db2cfc /src
parentd528c78ecfa75878e1bb4ea605bcafbbb2e63371 (diff)
downloadgnunet-63c92bbef932b831de7741ecc45c21915bfda82a.tar.gz
gnunet-63c92bbef932b831de7741ecc45c21915bfda82a.zip
add json response headers to rest plugins
Diffstat (limited to 'src')
-rw-r--r--src/gns/plugin_rest_gns.c2
-rw-r--r--src/identity/plugin_rest_identity.c7
-rw-r--r--src/peerinfo-tool/plugin_rest_peerinfo.c2
-rw-r--r--src/rest/plugin_rest_config.c1
4 files changed, 9 insertions, 3 deletions
diff --git a/src/gns/plugin_rest_gns.c b/src/gns/plugin_rest_gns.c
index 81c2c974b..feb333350 100644
--- a/src/gns/plugin_rest_gns.c
+++ b/src/gns/plugin_rest_gns.c
@@ -200,6 +200,7 @@ do_error (void *cls)
200 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR; 200 handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
201 response = json_dumps (json_error, 0); 201 response = json_dumps (json_error, 0);
202 resp = GNUNET_REST_create_response (response); 202 resp = GNUNET_REST_create_response (response);
203 MHD_add_response_header (resp, "Content-Type", "application/json");
203 handle->proc (handle->proc_cls, resp, handle->response_code); 204 handle->proc (handle->proc_cls, resp, handle->response_code);
204 json_decref (json_error); 205 json_decref (json_error);
205 GNUNET_free (response); 206 GNUNET_free (response);
@@ -252,6 +253,7 @@ handle_gns_response (void *cls,
252 result = json_dumps (result_obj, 0); 253 result = json_dumps (result_obj, 0);
253 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result); 254 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
254 resp = GNUNET_REST_create_response (result); 255 resp = GNUNET_REST_create_response (result);
256 MHD_add_response_header (resp, "Content-Type", "application/json");
255 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 257 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
256 GNUNET_free (result); 258 GNUNET_free (result);
257 json_decref (result_obj); 259 json_decref (result_obj);
diff --git a/src/identity/plugin_rest_identity.c b/src/identity/plugin_rest_identity.c
index 4b3571996..97a7bf513 100644
--- a/src/identity/plugin_rest_identity.c
+++ b/src/identity/plugin_rest_identity.c
@@ -309,6 +309,7 @@ do_error (void *cls)
309 handle->response_code = MHD_HTTP_OK; 309 handle->response_code = MHD_HTTP_OK;
310 response = json_dumps (json_error, 0); 310 response = json_dumps (json_error, 0);
311 resp = GNUNET_REST_create_response (response); 311 resp = GNUNET_REST_create_response (response);
312 MHD_add_response_header (resp, "Content-Type", "application/json");
312 handle->proc (handle->proc_cls, resp, handle->response_code); 313 handle->proc (handle->proc_cls, resp, handle->response_code);
313 json_decref (json_error); 314 json_decref (json_error);
314 GNUNET_free (response); 315 GNUNET_free (response);
@@ -398,7 +399,7 @@ ego_get_for_subsystem (void *cls,
398 result_str = json_dumps (json_root, 0); 399 result_str = json_dumps (json_root, 0);
399 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 400 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
400 resp = GNUNET_REST_create_response (result_str); 401 resp = GNUNET_REST_create_response (result_str);
401 402 MHD_add_response_header (resp, "Content-Type", "application/json");
402 json_decref (json_root); 403 json_decref (json_root);
403 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 404 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
404 GNUNET_free (result_str); 405 GNUNET_free (result_str);
@@ -485,7 +486,7 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle,
485 result_str = json_dumps (json_root, 0); 486 result_str = json_dumps (json_root, 0);
486 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 487 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
487 resp = GNUNET_REST_create_response (result_str); 488 resp = GNUNET_REST_create_response (result_str);
488 489 MHD_add_response_header (resp, "Content-Type", "application/json");
489 json_decref (json_root); 490 json_decref (json_root);
490 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 491 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
491 GNUNET_free (result_str); 492 GNUNET_free (result_str);
@@ -518,7 +519,7 @@ ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry)
518 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 519 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
519 resp = GNUNET_REST_create_response (result_str); 520 resp = GNUNET_REST_create_response (result_str);
520 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 521 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
521 522 MHD_add_response_header (resp, "Content-Type", "application/json");
522 json_decref (json_ego); 523 json_decref (json_ego);
523 GNUNET_free (result_str); 524 GNUNET_free (result_str);
524 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 525 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
diff --git a/src/peerinfo-tool/plugin_rest_peerinfo.c b/src/peerinfo-tool/plugin_rest_peerinfo.c
index 6e156569a..514b14313 100644
--- a/src/peerinfo-tool/plugin_rest_peerinfo.c
+++ b/src/peerinfo-tool/plugin_rest_peerinfo.c
@@ -326,6 +326,7 @@ do_error (void *cls)
326 handle->response_code = MHD_HTTP_OK; 326 handle->response_code = MHD_HTTP_OK;
327 response = json_dumps (json_error, 0); 327 response = json_dumps (json_error, 0);
328 resp = GNUNET_REST_create_response (response); 328 resp = GNUNET_REST_create_response (response);
329 MHD_add_response_header (resp, "Content-Type", "application/json");
329 handle->proc (handle->proc_cls, resp, handle->response_code); 330 handle->proc (handle->proc_cls, resp, handle->response_code);
330 json_decref (json_error); 331 json_decref (json_error);
331 GNUNET_free (response); 332 GNUNET_free (response);
@@ -356,6 +357,7 @@ peerinfo_list_finished (void *cls)
356 result_str = json_dumps (handle->response, 0); 357 result_str = json_dumps (handle->response, 0);
357 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str); 358 GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
358 resp = GNUNET_REST_create_response (result_str); 359 resp = GNUNET_REST_create_response (result_str);
360 MHD_add_response_header (resp, "Content-Type", "application/json");
359 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 361 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
360 GNUNET_free_non_null (result_str); 362 GNUNET_free_non_null (result_str);
361 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle); 363 GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);
diff --git a/src/rest/plugin_rest_config.c b/src/rest/plugin_rest_config.c
index d89c858ee..43dea1b9f 100644
--- a/src/rest/plugin_rest_config.c
+++ b/src/rest/plugin_rest_config.c
@@ -175,6 +175,7 @@ get_cont (struct GNUNET_REST_RequestHandle *con_handle,
175 } 175 }
176 response = json_dumps (result, 0); 176 response = json_dumps (result, 0);
177 resp = GNUNET_REST_create_response (response); 177 resp = GNUNET_REST_create_response (response);
178 MHD_add_response_header (resp, "Content-Type", "application/json");
178 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK); 179 handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
179 cleanup_handle (handle); 180 cleanup_handle (handle);
180 GNUNET_free (response); 181 GNUNET_free (response);