From 24daa5813f277023f7b8453338870369bf00a3ca Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Sat, 4 Jul 2026 04:03:12 +0000 Subject: Implement FastCGI, initial version --- src/libtipidee/tipidee_fcgi_put.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/libtipidee/tipidee_fcgi_put.c (limited to 'src/libtipidee/tipidee_fcgi_put.c') diff --git a/src/libtipidee/tipidee_fcgi_put.c b/src/libtipidee/tipidee_fcgi_put.c new file mode 100644 index 0000000..0f4b493 --- /dev/null +++ b/src/libtipidee/tipidee_fcgi_put.c @@ -0,0 +1,34 @@ +/* ISC license. */ + +#include + +#include +#include +#include + +#include + +static uint16_t putit (tipidee_fcgi *fc, uint8_t rectype, char const *s, uint16_t len, tain *stamp) +{ + char hdr[8] = { 1, (char)rectype, fc->id >> 8, fc->id & 0xff, 0, 0, 0, 0 } ; + uint16_t w ; + uint16_pack_big(hdr + 4, len) ; + w = buffer_timed_put(&fc->b, hdr, 8, &fc->deadline, stamp) ; + if (w < 8) return 0 ; + return buffer_timed_put(&fc->b, s, len, &fc->deadline, stamp) ; +} + +size_t tipidee_fcgi_put (tipidee_fcgi *fc, uint8_t rectype, char const *s, size_t len, tain *stamp) +{ + size_t w = 0 ; + while (len > 0xffffu) + { + uint16_t r = putit(fc, rectype, s, 0xffffu, stamp) ; + w += r ; + if (r < 0xffffu) return w ; + s += 0xffff ; + len -= 0xffff ; + } + w += putit(fc, rectype, s, len, stamp) ; + return w ; +} -- cgit v1.3.1