Commit d245b026 authored by Philipp Schafft's avatar Philipp Schafft 🦁

Feature: Support <http-headers> in <listen-socket>

Closes: #2359
parent 1c98b77a
Pipeline #2198 failed with stage
......@@ -657,6 +657,7 @@ listener_t *config_clear_listener(listener_t *listener)
if (listener->bind_address) xmlFree(listener->bind_address);
if (listener->shoutcast_mount) xmlFree(listener->shoutcast_mount);
if (listener->authstack) auth_stack_release(listener->authstack);
if (listener->http_headers) config_clear_http_header(listener->http_headers);
free (listener);
}
return next;
......@@ -1949,6 +1950,8 @@ static void _parse_listen_socket(xmlDocPtr doc,
__read_int(doc, node, &listener->listen_backlog, "<listen-backlog> must not be empty.");
} else if (xmlStrcmp(node->name, XMLSTR("authentication")) == 0) {
_parse_authentication_node(node, &(listener->authstack));
} else if (xmlStrcmp(node->name, XMLSTR("http-headers")) == 0) {
config_parse_http_headers(node->xmlChildrenNode, &(listener->http_headers));
}
} while ((node = node->next));
......@@ -2733,6 +2736,8 @@ listener_t *config_copy_listener_one(const listener_t *listener) {
if (listener->authstack) {
auth_stack_addref(n->authstack = listener->authstack);
}
if (listener->http_headers)
n->http_headers = config_copy_http_header(listener->http_headers);
return n;
}
......@@ -173,6 +173,8 @@ typedef struct _listener_t {
char *shoutcast_mount;
tlsmode_t tls;
auth_stack_t *authstack;
/* additional HTTP headers */
ice_config_http_header_t *http_headers;
} listener_t;
typedef struct _config_tls_context {
......
......@@ -52,6 +52,7 @@
#include "admin.h"
#include "auth.h"
#include "acl.h"
#include "listensocket.h"
#define CATMODULE "util"
......@@ -698,6 +699,14 @@ static inline char * _build_headers(int status, const char *allow, ice_config_t
if (client && client->acl && (header = acl_get_http_headers(client->acl)))
_build_headers_loop(&ret, &len, header, status, allow, client);
if (client && client->con && client->con->listensocket_effective) {
const listener_t * listener = listensocket_get_listener(client->con->listensocket_effective);
if ((header = listener->http_headers))
_build_headers_loop(&ret, &len, header, status, allow, client);
listensocket_release_listener(client->con->listensocket_effective);
}
return ret;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment