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/libtipidee/tipidee_response_status.c | |
| download | tipidee-17c382d1c9d7236c101418060758d2296cc5e17e.tar.gz | |
Initial commit
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_response_status.c')
| -rw-r--r-- | src/libtipidee/tipidee_response_status.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/libtipidee/tipidee_response_status.c b/src/libtipidee/tipidee_response_status.c new file mode 100644 index 0000000..aedec39 --- /dev/null +++ b/src/libtipidee/tipidee_response_status.c @@ -0,0 +1,27 @@ +/* ISC license. */ + +#include <skalibs/types.h> +#include <skalibs/buffer.h> + +#include <tipidee/response.h> + +size_t tipidee_response_status (buffer *b, tipidee_rql const *rql, unsigned int status, char const *line) +{ + size_t n = 0 ; + char fmt[UINT_FMT] ; + n += buffer_putnoflush(b, "HTTP/", 5) ; + n += buffer_putnoflush(b, fmt, uint_fmt(fmt, rql->http_major ? rql->http_major : 1)) ; + n += buffer_putnoflush(b, ".", 1) ; + n += buffer_putnoflush(b, fmt, uint_fmt(fmt, rql->http_major ? rql->http_minor : 1)) ; + n += buffer_putnoflush(b, " ", 1) ; + if (status) + { + char fmt[UINT_FMT] ; + size_t m = uint_fmt(fmt, status) ; + n += buffer_putnoflush(b, fmt, m) ; + n += buffer_putnoflush(b, " ", 1) ; + } + n += buffer_putsnoflush(b, line) ; + n += buffer_putnoflush(b, "\r\n", 2) ; + return n ; +} |
