diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-08-05 11:51:25 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-08-05 11:51:25 +0000 |
commit | 17c382d1c9d7236c101418060758d2296cc5e17e (patch) | |
tree | fd00e58df0d9d3c70ddd1accfec9e819249c672a /src/tipideed/options.c | |
download | tipidee-17c382d1c9d7236c101418060758d2296cc5e17e.tar.xz |
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/tipideed/options.c')
-rw-r--r-- | src/tipideed/options.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/tipideed/options.c b/src/tipideed/options.c new file mode 100644 index 0000000..d425943 --- /dev/null +++ b/src/tipideed/options.c @@ -0,0 +1,25 @@ +/* ISC license. */ + +#include <string.h> + +#include <skalibs/buffer.h> +#include <skalibs/strerr.h> +#include <skalibs/tai.h> +#include <skalibs/unix-timed.h> + +#include <tipidee/response.h> +#include "tipideed-internal.h" + +int respond_options (tipidee_rql const *rql, uint32_t flags) +{ + tain deadline ; + tipidee_response_status_line(buffer_1, rql, "200 OK") ; + tipidee_response_header_common_put_g(buffer_1, 0) ; + buffer_putsnoflush(buffer_1, "Content-Length: 0\r\nAllow: GET, HEAD") ; + if (flags & 1) buffer_putsnoflush(buffer_1, ", POST") ; + buffer_putnoflush(buffer_1, "\r\n\r\n", 4) ; + tain_add_g(&deadline, &g.writetto) ; + if (!buffer_timed_flush_g(buffer_1, &deadline)) + strerr_diefu1sys(111, "write to stdout") ; + return 0 ; +} |