Skip to content
This repository was archived by the owner on Oct 8, 2025. It is now read-only.

Commit d62b8e9

Browse files
committed
examples/rust: Update for new API additions
Update the echo-request and upload-reflector examples for the new uwr_http_add_header_content_type() and uwr_http_add_header_content_len() functions. Signed-off-by: Andrew Clayton <a.clayton@nginx.com>
1 parent 71ba509 commit d62b8e9

File tree

2 files changed

+3
-7
lines changed
  • examples/rust

2 files changed

+3
-7
lines changed

examples/rust/echo-request/src/lib.rs

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -102,12 +102,8 @@ pub extern "C" fn uwr_request_handler(addr: *mut u8) -> i32 {
102102
// storing the response headers at the beginning of our shared
103103
// memory at offset 0.
104104
uwr_http_init_headers(ctx, 2, 0);
105-
uwr_http_add_header(ctx, "Content-Type", "text/plain");
106-
uwr_http_add_header(
107-
ctx,
108-
"Content-Length",
109-
&format!("{}", uwr_get_response_data_size(ctx)),
110-
);
105+
uwr_http_add_header_content_type(ctx, "text/plain");
106+
uwr_http_add_header_content_len(ctx);
111107

112108
// This calls nxt_wasm_send_headers() in Unit
113109
uwr_http_send_headers(ctx);

examples/rust/upload-reflector/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ pub fn upload_reflector(ctx: *mut luw_ctx_t) -> i32 {
4949
}
5050

5151
uwr_http_init_headers(ctx, 2, 0);
52-
uwr_http_add_header(ctx, "Content-Type", ct);
52+
uwr_http_add_header_content_type(ctx, ct);
5353
uwr_http_add_header(
5454
ctx,
5555
"Content-Length",

0 commit comments

Comments
 (0)