summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2023-10-26 10:04:27 +0000
committerLaurent Bercot <ska@appnovation.com>2023-10-26 10:04:27 +0000
commit3dd236a9d8ff1fa0a754b359ceda12e85a123fff (patch)
treed6ce5d6f3e4c94068af83abc93ea54b606057318 /src
parenta1759ab3a80f594c1660dec8351fbcde9b516ff0 (diff)
downloadtipidee-3dd236a9d8ff1fa0a754b359ceda12e85a123fff.tar.xz
Fix custom header ordering
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src')
-rw-r--r--src/config/headers.c20
1 files changed, 9 insertions, 11 deletions
diff --git a/src/config/headers.c b/src/config/headers.c
index 351b938..829b898 100644
--- a/src/config/headers.c
+++ b/src/config/headers.c
@@ -81,20 +81,19 @@ void headers_addv (char const *key, uint8_t options, char const *s, size_t const
repo_add(&headers, &node) ;
}
-static uint32_t headers_defaults (node *node)
+static inline void headers_defaults (void)
{
- uint32_t n = 0 ;
for (size_t i = 0 ; i < sizeof(builtinheaders) / sizeof(struct builtinheaders_s) ; i++)
{
+ node node ;
struct builtinheaders_s const *p = builtinheaders + i ;
if (!p->value) continue ;
if (p->overridable && headers_search(p->key)) continue ;
- confnode_add(node, p->key, strlen(p->key) + 1) ;
- confnode_add(node, p->overridable ? "\1" : "", 1) ;
- confnode_add(node, p->value, strlen(p->value) + 1) ;
- n++ ;
+ node_start(&headers_storage, &node, p->key, 0, 0) ;
+ node_add(&headers_storage, &node, p->overridable ? "\1" : "", 1) ;
+ node_add(&headers_storage, &node, p->value, strlen(p->value) + 1) ;
+ repo_add(&headers, &node) ;
}
- return n ;
}
static int header_write (uint32_t d, unsigned int h, void *data)
@@ -109,13 +108,12 @@ static int header_write (uint32_t d, unsigned int h, void *data)
void headers_finish (void)
{
- uint32_t n ;
- char pack[4] ;
node node ;
+ char pack[4] ;
+ headers_defaults() ;
+ uint32_pack_big(pack, avltree_len(&headers.tree)) ;
confnode_start(&node, "G:response_headers", 0, 0) ;
- n = avltree_len(&headers.tree) + headers_defaults(&node) ;
(void)avltree_iter(&headers.tree, &header_write, &node) ;
- uint32_pack_big(pack, n) ;
confnode_add(&node, pack, 4) ;
conftree_add(&node) ;
avltree_free(&headers.tree) ;