]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Stop prettifying JSON statistics
authorMichał Kępień <michal@isc.org>
Mon, 27 Oct 2025 09:56:38 +0000 (10:56 +0100)
committerMichał Kępień <michal@isc.org>
Mon, 27 Oct 2025 09:56:38 +0000 (10:56 +0100)
Passing the JSON_C_TO_STRING_PRETTY flag to
json_object_to_json_string_ext() makes the latter produce prettified
JSON output.  This results in a huge amount of redundant whitespace
being inserted into each HTTP response (whitespace amounts to about 40%
of the entire JSON payload).

The bandwidth cost can be amortized by enabling HTTP compression on the
client side ("Accept-Encoding: deflate"), but that does not affect the
size of data at rest.

Use the JSON_C_TO_STRING_PLAIN flag instead of JSON_C_TO_STRING_PRETTY
to minimize the size of JSON responses sent via the statistics channel.
External tools should be used for prettifying JSON data.

bin/named/statschannel.c

index d0a235e290a596da5549cb84fc15e984148e9d48..eacb2d25eaa2c4342191adc48d125a9a681f58c6 100644 (file)
@@ -3332,7 +3332,7 @@ generatejson(named_server_t *server, size_t *msglen, const char **msg,
        }
 
        *msg = json_object_to_json_string_ext(bindstats,
-                                             JSON_C_TO_STRING_PRETTY);
+                                             JSON_C_TO_STRING_PLAIN);
        *msglen = strlen(*msg);
 
        if (rootp != NULL) {