summaryrefslogtreecommitdiffhomepage
path: root/src/rust/unit-wasm-sys/rusty.rs
diff options
context:
space:
mode:
authorAndrew Clayton <a.clayton@nginx.com>2023-08-29 23:31:47 +0100
committerAndrew Clayton <a.clayton@nginx.com>2023-08-29 23:41:11 +0100
commit04197e036a01d3826e0529f1396924a868bb4dd2 (patch)
tree6601e10c01081143b4187d135b580331a910f8fd /src/rust/unit-wasm-sys/rusty.rs
parent5dc0cf051059ac83899b55f4a55df363faea4419 (diff)
downloadunit-wasm-04197e036a01d3826e0529f1396924a868bb4dd2.tar.gz
unit-wasm-04197e036a01d3826e0529f1396924a868bb4dd2.tar.bz2
Rust/rusty: Make use of uwr_get_http_total_content_sent()
When the uwr_get_http_content_str() function, which returns the request body content as a string, was added it used uwr_get_http_content_len() to determine the length of the returned string (the request body content is not null-terminated). This could potentially in some circumstances return too much data if the request was split over multiple calls into the Wasm module and uwr_get_http_content_str() was called before all the data had actually been received. Instead use the newly introduced uwr_get_http_total_content_sent() function to determine the amount of data to return in the string as it currently stands. Fixes: bf968c9 ("Rust/rusty: Add uwr_get_http_content_str()") Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
Diffstat (limited to '')
-rw-r--r--src/rust/unit-wasm-sys/rusty.rs2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/rust/unit-wasm-sys/rusty.rs b/src/rust/unit-wasm-sys/rusty.rs
index 81b3e5b..3ef7e82 100644
--- a/src/rust/unit-wasm-sys/rusty.rs
+++ b/src/rust/unit-wasm-sys/rusty.rs
@@ -115,7 +115,7 @@ pub fn uwr_get_http_content_str(ctx: *const luw_ctx_t) -> &'static str {
unsafe {
let slice = slice::from_raw_parts(
uwr_get_http_content(ctx),
- uwr_get_http_content_len(ctx),
+ uwr_get_http_total_content_sent(ctx),
);
str::from_utf8(slice).unwrap()
}