This repository was archived by the owner on Oct 8, 2025. It is now read-only.
Commit 1dd1b34
committed
libunit-wasm: Add a luw_req_buf_copy() function
This is analogous to luw_req_buf_append() but rather than appending
request data to the buffer it simply overwrites what's currently there.
This is needed to take advantage of the new ability to receive >4GiB
requests/payloads.
On a new request you would call luw_init_ctx(), luw_set_req_buf() &
open(2).
On subsequent calls to the request_handler (for this same HTTP
request/upload) you would call this new function and then write out the
data to a file.
E.g
/* In the request_handler */
if (total_bytes_wrote == 0) {
luw_init_ctx(&ctx, addr, 0);
luw_set_req_buf(&ctx, &request_buf, LUW_SRB_NONE);
fd = open("/var/tmp/large-file.dat", O_CREAT|O_TRUNC|O_WRONLY,
0666);
} else {
luw_req_buf_copy(&ctx, addr);
}
buf = luw_get_http_content(&ctx);
bytes_wrote = write(fd, buf, luw_get_http_content_sent(&ctx));
total_bytes_wrote += bytes_wrote;
if (total_bytes_wrote == luw_get_http_content_len(&ctx)) {
close(fd);
total_bytes_wrote = 0;
luw_http_response_end();
}
Signed-off-by: Andrew Clayton <a.clayton@nginx.com>1 parent 263541e commit 1dd1b34
2 files changed
+12
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
238 | 238 | | |
239 | 239 | | |
240 | 240 | | |
| 241 | + | |
241 | 242 | | |
242 | 243 | | |
243 | 244 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
304 | 304 | | |
305 | 305 | | |
306 | 306 | | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
307 | 318 | | |
308 | 319 | | |
309 | 320 | | |
| |||
0 commit comments