From 51d0fdce74aeb23ef28336037b2d35aa4c955cee Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Wed, 20 Dec 2023 14:08:25 +0000 Subject: Major refactors; implement ranges Signed-off-by: Laurent Bercot --- src/libtipidee/tipidee_response_file.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'src/libtipidee/tipidee_response_file.c') diff --git a/src/libtipidee/tipidee_response_file.c b/src/libtipidee/tipidee_response_file.c index f2021ee..b64d086 100644 --- a/src/libtipidee/tipidee_response_file.c +++ b/src/libtipidee/tipidee_response_file.c @@ -2,18 +2,15 @@ #include -#include +#include #include -#include -#include -#include #include -#include -size_t tipidee_response_file (buffer *b, tipidee_rql const *rql, unsigned int status, char const *reason, struct stat const *st, char const *ct, tipidee_response_header const *rhdr, uint32_t rhdrn, uint32_t options, tain const *stamp) +size_t tipidee_response_file (buffer *b, tipidee_rql const *rql, unsigned int status, char const *reason, struct stat const *st, uint64_t cl, char const *ct, tipidee_response_header const *rhdr, uint32_t rhdrn, uint32_t options, tain const *stamp) { char fmt[128] ; + tipidee_response_header v[2] = { { .key = "Content-Type", .value = ct, .options = 0 }, { .key = "Content-Length", .value = fmt, .options = 0 } } ; size_t n = tipidee_response_status(b, rql, status, reason) ; n += tipidee_response_header_writeall(b, rhdr, rhdrn, options & 1, stamp) ; if (options & 2) @@ -21,11 +18,7 @@ size_t tipidee_response_file (buffer *b, tipidee_rql const *rql, unsigned int st size_t l = tipidee_response_header_lastmodified(fmt, 128, st) ; if (l) n += buffer_putnoflush(b, fmt, l) ; } - n += buffer_putsnoflush(b, "Content-Type: ") ; - n += buffer_putsnoflush(b, ct) ; - n += buffer_putsnoflush(b, "\r\nContent-Length: ") ; - fmt[uint64_fmt(fmt, st->st_size)] = 0 ; - n += buffer_putsnoflush(b, fmt) ; - n += buffer_putnoflush(b, "\r\n\r\n", 4) ; + fmt[uint64_fmt(fmt, cl)] = 0 ; + n += tipidee_response_header_write(b, v, 2) ; return n ; } -- cgit v1.2.3