瀏覽代碼

add json response headers to rest plugins

Schanzenbach, Martin 4 年之前
父節點
當前提交
63c92bbef9

+ 2 - 0
src/gns/plugin_rest_gns.c

@@ -200,6 +200,7 @@ do_error (void *cls)
     handle->response_code = MHD_HTTP_INTERNAL_SERVER_ERROR;
   response = json_dumps (json_error, 0);
   resp = GNUNET_REST_create_response (response);
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   handle->proc (handle->proc_cls, resp, handle->response_code);
   json_decref (json_error);
   GNUNET_free (response);
@@ -252,6 +253,7 @@ handle_gns_response (void *cls,
   result = json_dumps (result_obj, 0);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result);
   resp = GNUNET_REST_create_response (result);
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
   GNUNET_free (result);
   json_decref (result_obj);

+ 4 - 3
src/identity/plugin_rest_identity.c

@@ -309,6 +309,7 @@ do_error (void *cls)
     handle->response_code = MHD_HTTP_OK;
   response = json_dumps (json_error, 0);
   resp = GNUNET_REST_create_response (response);
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   handle->proc (handle->proc_cls, resp, handle->response_code);
   json_decref (json_error);
   GNUNET_free (response);
@@ -398,7 +399,7 @@ ego_get_for_subsystem (void *cls,
   result_str = json_dumps (json_root, 0);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
   resp = GNUNET_REST_create_response (result_str);
-
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   json_decref (json_root);
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
   GNUNET_free (result_str);
@@ -485,7 +486,7 @@ ego_get_all (struct GNUNET_REST_RequestHandle *con_handle,
   result_str = json_dumps (json_root, 0);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
   resp = GNUNET_REST_create_response (result_str);
-
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   json_decref (json_root);
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
   GNUNET_free (result_str);
@@ -518,7 +519,7 @@ ego_get_response (struct RequestHandle *handle, struct EgoEntry *ego_entry)
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
   resp = GNUNET_REST_create_response (result_str);
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
-
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   json_decref (json_ego);
   GNUNET_free (result_str);
   GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);

+ 2 - 0
src/peerinfo-tool/plugin_rest_peerinfo.c

@@ -326,6 +326,7 @@ do_error (void *cls)
     handle->response_code = MHD_HTTP_OK;
   response = json_dumps (json_error, 0);
   resp = GNUNET_REST_create_response (response);
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   handle->proc (handle->proc_cls, resp, handle->response_code);
   json_decref (json_error);
   GNUNET_free (response);
@@ -356,6 +357,7 @@ peerinfo_list_finished (void *cls)
   result_str = json_dumps (handle->response, 0);
   GNUNET_log (GNUNET_ERROR_TYPE_DEBUG, "Result %s\n", result_str);
   resp = GNUNET_REST_create_response (result_str);
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
   GNUNET_free_non_null (result_str);
   GNUNET_SCHEDULER_add_now (&cleanup_handle, handle);

+ 1 - 0
src/rest/plugin_rest_config.c

@@ -175,6 +175,7 @@ get_cont (struct GNUNET_REST_RequestHandle *con_handle,
   }
   response = json_dumps (result, 0);
   resp = GNUNET_REST_create_response (response);
+  MHD_add_response_header (resp, "Content-Type", "application/json");
   handle->proc (handle->proc_cls, resp, MHD_HTTP_OK);
   cleanup_handle (handle);
   GNUNET_free (response);