From da5d9dc03b14b4d0f1ce0ce3ff093f387e148706 Mon Sep 17 00:00:00 2001 From: Andrew Clayton Date: Mon, 28 Aug 2023 16:11:15 +0100 Subject: libunit-wasm: Remove the idx argument from luw_http_add_header() This was used to specify the index of the response header being added, starting at 0 and incrementing by one for each header. Instead of having the programmer specify this, track it internally. We add an extra check in luw_http_add_header() to make sure we aren't trying to add more headers than we said with luw_http_init_headers(), if we are, simply return. This updates the API-C.md and the various examples and 'rusty' API wrapper. Suggested-by: Liam Crilly Signed-off-by: Andrew Clayton --- src/rust/unit-wasm-sys/rusty.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/rust') diff --git a/src/rust/unit-wasm-sys/rusty.rs b/src/rust/unit-wasm-sys/rusty.rs index 79c38f3..fbfecd3 100644 --- a/src/rust/unit-wasm-sys/rusty.rs +++ b/src/rust/unit-wasm-sys/rusty.rs @@ -43,6 +43,7 @@ pub const fn UWR_CTX_INITIALIZER() -> luw_ctx_t { req_buf: null_mut(), hdrp: null_mut(), reqp: null_mut(), + resp_hdr_idx: -1, } } @@ -173,14 +174,12 @@ pub fn uwr_http_init_headers(ctx: *mut luw_ctx_t, nr: usize, offset: usize) { pub fn uwr_http_add_header( ctx: *mut luw_ctx_t, - idx: u16, name: &str, value: &str, ) { unsafe { luw_http_add_header( ctx, - idx, S2C!(name).as_ptr() as *const i8, S2C!(value).as_ptr() as *const i8, ); -- cgit