1
0
Fork 0

Update: Added warning about JSON rendering

This commit is contained in:
Philipp Schafft 2022-03-11 19:04:38 +00:00
parent 29dd621a08
commit 979c336b5b
2 changed files with 8 additions and 4 deletions

View File

@ -568,7 +568,7 @@ void admin_send_response(xmlDocPtr doc,
}
json = xml2json_render_doc_simple(doc, ns);
client_send_buffer(client, 200, "application/json", "utf-8", json, -1, NULL);
client_send_buffer(client, 200, "application/json", "utf-8", json, -1, "Warning: 299 - \"JSON rendering is experimental\"\r\n");
free(json);
}
} else if (response == ADMIN_FORMAT_HTML) {

View File

@ -704,14 +704,18 @@ void client_send_reportxml(client_t *client, reportxml_t *report, document_domai
}
if (admin_format == ADMIN_FORMAT_RAW || admin_format == ADMIN_FORMAT_JSON) {
char extra_header[512] = "";
static const char json_warning[] = "Warning: 299 - \"JSON rendering is experimental\"\r\n";
char extra_header_buffer[512] = "";
const char *extra_header = extra_header_buffer;
if (location) {
int res = snprintf(extra_header, sizeof(extra_header), "Location: %s\r\n", location);
if (res < 0 || res >= (ssize_t)sizeof(extra_header)) {
int res = snprintf(extra_header_buffer, sizeof(extra_header_buffer), "Location: %s\r\n%s", location, admin_format == ADMIN_FORMAT_JSON ? json_warning : "");
if (res < 0 || res >= (ssize_t)sizeof(extra_header_buffer)) {
client_send_error_by_id(client, ICECAST_ERROR_GEN_HEADER_GEN_FAILED);
return;
}
} else if (admin_format == ADMIN_FORMAT_JSON) {
extra_header = json_warning;
}
if (admin_format == ADMIN_FORMAT_RAW) {