diff options
Diffstat (limited to 'src/rust/unit-wasm-sys/rusty.rs')
-rw-r--r-- | src/rust/unit-wasm-sys/rusty.rs | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/rust/unit-wasm-sys/rusty.rs b/src/rust/unit-wasm-sys/rusty.rs index 3c96d02..3bff4df 100644 --- a/src/rust/unit-wasm-sys/rusty.rs +++ b/src/rust/unit-wasm-sys/rusty.rs @@ -9,6 +9,8 @@ use std::ffi::c_char; use std::ffi::c_void; use std::ffi::CStr; use std::ptr::null_mut; +use std::slice; +use std::str; #[macro_export] macro_rules! C2S { @@ -101,6 +103,16 @@ pub fn uwr_get_http_content_len(ctx: *const luw_ctx_t) -> usize { unsafe { luw_get_http_content_len(ctx) } } +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), + ); + str::from_utf8(slice).unwrap() + } +} + pub fn uwr_get_http_content_sent(ctx: *const luw_ctx_t) -> usize { unsafe { luw_get_http_content_sent(ctx) } } |