diff options
author | Laurent Bercot <ska-skaware@skarnet.org> | 2023-12-20 14:08:25 +0000 |
---|---|---|
committer | Laurent Bercot <ska@appnovation.com> | 2023-12-20 14:08:25 +0000 |
commit | 51d0fdce74aeb23ef28336037b2d35aa4c955cee (patch) | |
tree | 9c178c8e6756ec770b85efd54235cd7c2a97888f /src/libtipidee/tipidee_response_file.c | |
parent | d2959364ef8d6bc948474a8facf497788b4e768b (diff) | |
download | tipidee-51d0fdce74aeb23ef28336037b2d35aa4c955cee.tar.xz |
Major refactors; implement ranges
Signed-off-by: Laurent Bercot <ska@appnovation.com>
Diffstat (limited to 'src/libtipidee/tipidee_response_file.c')
-rw-r--r-- | src/libtipidee/tipidee_response_file.c | 17 |
1 files changed, 5 insertions, 12 deletions
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 <stddef.h> -#include <skalibs/types.h> +#include <skalibs/uint64.h> #include <skalibs/buffer.h> -#include <tipidee/conf.h> -#include <tipidee/method.h> -#include <tipidee/rql.h> #include <tipidee/response.h> -#include <tipidee/util.h> -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 ; } |