From b9aa69720631139f253d8b6953f28fb0b3449cd2 Mon Sep 17 00:00:00 2001 From: Jason Volk Date: Tue, 2 Oct 2018 15:47:43 -0700 Subject: [PATCH] ircd::resource: Make Access-Control-Allow-Origin response header a conf item. --- include/ircd/resource.h | 1 + ircd/resource.cc | 11 +++++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/include/ircd/resource.h b/include/ircd/resource.h index 2dcd5c6d6..a122790b9 100644 --- a/include/ircd/resource.h +++ b/include/ircd/resource.h @@ -144,6 +144,7 @@ struct ircd::resource::response struct chunked; static const size_t HEAD_BUF_SZ; + static conf::item access_control_allow_origin; response(client &, const http::code &, const string_view &content_type, const size_t &content_length, const string_view &headers = {}); response(client &, const string_view &str, const string_view &content_type, const http::code &, const vector_view &); diff --git a/ircd/resource.cc b/ircd/resource.cc index 36648a72c..262685424 100644 --- a/ircd/resource.cc +++ b/ircd/resource.cc @@ -990,6 +990,13 @@ ircd::resource::response::response(client &client, assert(written == size(content)); } +decltype(ircd::resource::response::access_control_allow_origin) +ircd::resource::response::access_control_allow_origin +{ + { "name", "ircd.resource.access_control.allow_origin" }, + { "default", "*" } +}; + ircd::resource::response::response(client &client, const http::code &code, const string_view &content_type, @@ -1018,8 +1025,8 @@ ircd::resource::response::response(client &client, content_type, headers, { - { "Access-Control-Allow-Origin", "*" }, //TODO: XXX - { "X-IRCd-Request-Timer", rtime, }, + { "Access-Control-Allow-Origin", string_view(access_control_allow_origin) }, + { "X-IRCd-Request-Timer", rtime }, }, };