aboutsummaryrefslogtreecommitdiffstats
path: root/src/libtipidee/tipidee_response_header_builtin.c
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-08-05 11:51:25 +0000
committerLaurent Bercot <ska@appnovation.com>2023-08-05 11:51:25 +0000
commit17c382d1c9d7236c101418060758d2296cc5e17e (patch)
treefd00e58df0d9d3c70ddd1accfec9e819249c672a /src/libtipidee/tipidee_response_header_builtin.c
downloadtipidee-17c382d1c9d7236c101418060758d2296cc5e17e.tar.gz
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_response_header_builtin.c')
-rw-r--r--src/libtipidee/tipidee_response_header_builtin.c40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_response_header_builtin.c b/src/libtipidee/tipidee_response_header_builtin.c
new file mode 100644
index 0000000..0125cb8
--- /dev/null
+++ b/src/libtipidee/tipidee_response_header_builtin.c
@@ -0,0 +1,40 @@
+/* ISC license. */
+
+#include <string.h>
+#include <stdlib.h>
+
+#include <tipidee/config.h>
+#include <tipidee/response.h>
+
+static tipidee_response_header_builtin const tipidee_response_header_builtin_table_[] =
+{
+ { .key = "Accept-Ranges", .value = "none" },
+ { .key = "Cache-Control", .value = "private" },
+ { .key = "Content-Security-Policy", .value = "default-src 'self'; style-src 'self' 'unsafe-inline';" },
+ { .key = "Referrer-Policy", .value = "no-referrer-when-downgrade" },
+ { .key = "Server", .value = "tipidee/" TIPIDEE_VERSION },
+ { .key = "Vary", .value = "Accept-Encoding" },
+ { .key = "X-Content-Type-Options", .value = "nosniff" },
+ { .key = "X-Frame-Options", .value = "DENY" },
+ { .key = "X-XSS-Protection", .value = "1; mode=block" },
+ { .key = 0, .value = 0 },
+} ;
+
+tipidee_response_header_builtin const *tipidee_response_header_builtin_table = tipidee_response_header_builtin_table_ ;
+
+static int tipidee_response_header_builtin_cmp (void const *a, void const *b)
+{
+ return strcmp((char const *)a, ((tipidee_response_header_builtin const *)b)->key) ;
+}
+
+char const *tipidee_response_header_builtin_search (char const *key)
+{
+ tipidee_response_header_builtin const *p = bsearch(
+ key,
+ tipidee_response_header_builtin_table_,
+ sizeof(tipidee_response_header_builtin_table_) / sizeof(tipidee_response_header_builtin) - 1,
+ sizeof(tipidee_response_header_builtin),
+ &tipidee_response_header_builtin_cmp) ;
+ return p ? p->value : 0 ;
+}
+