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 --- examples/rust/echo-request/src/lib.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'examples/rust/echo-request/src/lib.rs') diff --git a/examples/rust/echo-request/src/lib.rs b/examples/rust/echo-request/src/lib.rs index 3fea8d5..235ad13 100644 --- a/examples/rust/echo-request/src/lib.rs +++ b/examples/rust/echo-request/src/lib.rs @@ -104,10 +104,9 @@ pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 { // storing the response headers at the beginning of our shared // memory at offset 0. uwr_http_init_headers(ctx, 2, 0); - uwr_http_add_header(ctx, 0, "Content-Type", "text/plain"); + uwr_http_add_header(ctx, "Content-Type", "text/plain"); uwr_http_add_header( ctx, - 1, "Content-Length", &format!("{}", uwr_get_response_data_size(ctx)), ); -- cgit