1
0
mirror of https://gitlab.xiph.org/xiph/icecast-server.git synced 2024-12-04 14:46:30 -05:00

Feature: Allow xslt_transform() to send non-200 status

This commit is contained in:
Philipp Schafft 2018-06-09 09:22:25 +00:00
parent d6a9530238
commit 32a410bdd6
4 changed files with 7 additions and 7 deletions

View File

@ -463,7 +463,7 @@ void admin_send_response(xmlDocPtr doc,
config_release_config(); config_release_config();
ICECAST_LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template); ICECAST_LOG_DEBUG("Sending XSLT (%s)", fullpath_xslt_template);
xslt_transform(doc, fullpath_xslt_template, client); xslt_transform(doc, fullpath_xslt_template, client, 200);
free(fullpath_xslt_template); free(fullpath_xslt_template);
} }
} }

View File

@ -1024,7 +1024,7 @@ void stats_transform_xslt(client_t *client, const char *uri)
doc = stats_get_xml(0, mount, client->mode); doc = stats_get_xml(0, mount, client->mode);
xslt_transform(doc, xslpath, client); xslt_transform(doc, xslpath, client, 200);
xmlFreeDoc(doc); xmlFreeDoc(doc);
free(xslpath); free(xslpath);

View File

@ -285,7 +285,7 @@ static xmlDocPtr custom_loader(const xmlChar *URI,
return ret; return ret;
} }
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client) void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, int status)
{ {
xmlDocPtr res; xmlDocPtr res;
xsltStylesheetPtr cur; xsltStylesheetPtr cur;
@ -346,7 +346,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
if (string == NULL) if (string == NULL)
string = xmlCharStrdup (""); string = xmlCharStrdup ("");
ret = util_http_build_header(refbuf->data, full_len, 0, 0, 200, NULL, mediatype, charset, NULL, NULL, client); ret = util_http_build_header(refbuf->data, full_len, 0, 0, status, NULL, mediatype, charset, NULL, NULL, client);
if (ret == -1) { if (ret == -1) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_error_by_id(client, ICECAST_ERROR_GEN_HEADER_GEN_FAILED); client_send_error_by_id(client, ICECAST_ERROR_GEN_HEADER_GEN_FAILED);
@ -359,7 +359,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
ICECAST_LOG_DEBUG("Client buffer reallocation succeeded."); ICECAST_LOG_DEBUG("Client buffer reallocation succeeded.");
refbuf->data = new_data; refbuf->data = new_data;
refbuf->len = full_len; refbuf->len = full_len;
ret = util_http_build_header(refbuf->data, full_len, 0, 0, 200, NULL, mediatype, charset, NULL, NULL, client); ret = util_http_build_header(refbuf->data, full_len, 0, 0, status, NULL, mediatype, charset, NULL, NULL, client);
if (ret == -1) { if (ret == -1) {
ICECAST_LOG_ERROR("Dropping client as we can not build response headers."); ICECAST_LOG_ERROR("Dropping client as we can not build response headers.");
client_send_error_by_id(client, ICECAST_ERROR_GEN_HEADER_GEN_FAILED); client_send_error_by_id(client, ICECAST_ERROR_GEN_HEADER_GEN_FAILED);
@ -375,7 +375,7 @@ void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client)
if (!failed) { if (!failed) {
snprintf(refbuf->data + ret, full_len - ret, "Content-Length: %d\r\n\r\n%s", len, string); snprintf(refbuf->data + ret, full_len - ret, "Content-Length: %d\r\n\r\n%s", len, string);
client->respcode = 200; client->respcode = status;
client_set_queue (client, NULL); client_set_queue (client, NULL);
client->refbuf = refbuf; client->refbuf = refbuf;
refbuf->len = strlen (refbuf->data); refbuf->len = strlen (refbuf->data);

View File

@ -16,7 +16,7 @@
#include "icecasttypes.h" #include "icecasttypes.h"
void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client); void xslt_transform(xmlDocPtr doc, const char *xslfilename, client_t *client, int status);
void xslt_initialize(void); void xslt_initialize(void);
void xslt_shutdown(void); void xslt_shutdown(void);