summaryrefslogtreecommitdiff
path: root/src/libtipidee/tipidee_response_header_common_put.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_common_put.c
downloadtipidee-17c382d1c9d7236c101418060758d2296cc5e17e.tar.xz
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_response_header_common_put.c')
-rw-r--r--src/libtipidee/tipidee_response_header_common_put.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_response_header_common_put.c b/src/libtipidee/tipidee_response_header_common_put.c
new file mode 100644
index 0000000..8352ba9
--- /dev/null
+++ b/src/libtipidee/tipidee_response_header_common_put.c
@@ -0,0 +1,23 @@
+/* ISC license. */
+
+#include <stdint.h>
+
+#include <skalibs/buffer.h>
+
+#include <tipidee/config.h>
+#include <tipidee/response.h>
+
+size_t tipidee_response_header_common_put (buffer *b, uint32_t options, tain const *stamp)
+{
+ char fmt[128] ;
+ size_t m = buffer_putnoflush(b, fmt, tipidee_response_header_date_fmt(fmt, 128, stamp)) ;
+ for (tipidee_response_header_builtin const *p = tipidee_response_header_builtin_table ; p->key ; p++)
+ {
+ m += buffer_putsnoflush(b, p->key) ;
+ m += buffer_putnoflush(b, ": ", 2) ;
+ m += buffer_putsnoflush(b, p->value) ;
+ m += buffer_putnoflush(b, "\r\n", 2) ;
+ }
+ if (options & 1) m += buffer_putsnoflush(b, "Connection: close\r\n") ;
+ return m ;
+}