From 59cb1e8000e1b18e317cb1c19185eb3a1b5d4e9f Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Tue, 29 Aug 2023 22:22:01 +0100 Subject: libunit-wasm: Add a luw_get_http_total_content_sent() function This function returns the total amount of content that the Wasm module has received so far. This will be used in the rusty API's uwr_get_http_content_str() function which returns the body content as a string. Due to the body content not being null-terminated we need to know how much data to use for the string, for which we are currently using uwr_get_http_content_len(), which could in some cases return too much if a request is being split over multiple calls the module. Signed-off-by: Andrew Clayton --- src/c/libunit-wasm.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'src/c/libunit-wasm.c') diff --git a/src/c/libunit-wasm.c b/src/c/libunit-wasm.c index c0c02c5..69fe4c0 100644 --- a/src/c/libunit-wasm.c +++ b/src/c/libunit-wasm.c @@ -207,6 +207,12 @@ size_t luw_get_http_content_sent(const luw_ctx_t *ctx) return ctx->req->content_sent; } +/* Returns the size of the overall content sent so far */ +size_t luw_get_http_total_content_sent(const luw_ctx_t *ctx) +{ + return ctx->req->total_content_sent; +} + bool luw_http_is_tls(const luw_ctx_t *ctx) { return ctx->req->tls; -- cgit