summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/c/include/unit/unit-wasm.h12
-rw-r--r--src/c/libunit-wasm.c4
-rw-r--r--src/rust/unit-wasm-sys/rusty.rs16
3 files changed, 20 insertions, 12 deletions
diff --git a/src/c/include/unit/unit-wasm.h b/src/c/include/unit/unit-wasm.h
index c870e30..f698c97 100644
--- a/src/c/include/unit/unit-wasm.h
+++ b/src/c/include/unit/unit-wasm.h
@@ -109,10 +109,10 @@ struct luw_req {
u32 server_name_off;
u32 server_name_len;
- u32 content_off;
- u32 content_len;
+ u64 content_len;
+ u64 total_content_sent;
u32 content_sent;
- u32 total_content_sent;
+ u32 content_off;
u32 request_size;
@@ -120,6 +120,8 @@ struct luw_req {
u32 tls;
+ char __pad[4];
+
struct luw_hdr_field fields[];
};
@@ -220,9 +222,9 @@ extern const char *luw_get_http_local_addr(const luw_ctx_t *ctx);
extern const char *luw_get_http_local_port(const luw_ctx_t *ctx);
extern const char *luw_get_http_server_name(const luw_ctx_t *ctx);
extern const u8 *luw_get_http_content(const luw_ctx_t *ctx);
-extern size_t luw_get_http_content_len(const luw_ctx_t *ctx);
+extern u64 luw_get_http_content_len(const luw_ctx_t *ctx);
extern size_t luw_get_http_content_sent(const luw_ctx_t *ctx);
-extern size_t luw_get_http_total_content_sent(const luw_ctx_t *ctx);
+extern u64 luw_get_http_total_content_sent(const luw_ctx_t *ctx);
extern bool luw_http_is_tls(const luw_ctx_t *ctx);
extern void luw_http_hdr_iter(luw_ctx_t *ctx,
bool (*luw_http_hdr_iter_func)(luw_ctx_t *ctx,
diff --git a/src/c/libunit-wasm.c b/src/c/libunit-wasm.c
index 165dcd7..28d5906 100644
--- a/src/c/libunit-wasm.c
+++ b/src/c/libunit-wasm.c
@@ -196,7 +196,7 @@ const u8 *luw_get_http_content(const luw_ctx_t *ctx)
}
/* Returns the size of the overall content length */
-size_t luw_get_http_content_len(const luw_ctx_t *ctx)
+u64 luw_get_http_content_len(const luw_ctx_t *ctx)
{
return ctx->req->content_len;
}
@@ -208,7 +208,7 @@ size_t luw_get_http_content_sent(const luw_ctx_t *ctx)
}
/* Returns the size of the overall content sent so far */
-size_t luw_get_http_total_content_sent(const luw_ctx_t *ctx)
+u64 luw_get_http_total_content_sent(const luw_ctx_t *ctx)
{
return ctx->req->total_content_sent;
}
diff --git a/src/rust/unit-wasm-sys/rusty.rs b/src/rust/unit-wasm-sys/rusty.rs
index 5d1fbad..bf9cd64 100644
--- a/src/rust/unit-wasm-sys/rusty.rs
+++ b/src/rust/unit-wasm-sys/rusty.rs
@@ -95,7 +95,7 @@ pub fn uwr_get_http_server_name(ctx: *const luw_ctx_t) -> &'static str {
C2S!(luw_get_http_server_name(ctx))
}
-pub fn uwr_get_http_content_len(ctx: *const luw_ctx_t) -> usize {
+pub fn uwr_get_http_content_len(ctx: *const luw_ctx_t) -> u64 {
unsafe { luw_get_http_content_len(ctx) }
}
@@ -103,7 +103,7 @@ pub fn uwr_get_http_content_sent(ctx: *const luw_ctx_t) -> usize {
unsafe { luw_get_http_content_sent(ctx) }
}
-pub fn uwr_get_http_total_content_sent(ctx: *const luw_ctx_t) -> usize {
+pub fn uwr_get_http_total_content_sent(ctx: *const luw_ctx_t) -> u64 {
unsafe { luw_get_http_total_content_sent(ctx) }
}
@@ -115,7 +115,7 @@ 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_total_content_sent(ctx),
+ uwr_get_http_total_content_sent(ctx).try_into().unwrap(),
);
str::from_utf8(slice).unwrap()
}
@@ -158,9 +158,15 @@ pub fn uwr_mem_write_str(ctx: *mut luw_ctx_t, src: &str) -> usize {
pub fn uwr_mem_write_buf(
ctx: *mut luw_ctx_t,
src: *const u8,
- size: usize,
+ size: u64,
) -> usize {
- unsafe { luw_mem_writep_data(ctx, src, size) }
+ /*
+ * We're dealing with a 32bit address space, but we allow
+ * size to come from the output of uwr_get_http_content_len()
+ * which returns a u64 to allow for larger than memory uploads.
+ */
+ let sz = size as usize;
+ unsafe { luw_mem_writep_data(ctx, src, sz) }
}
pub fn uwr_req_buf_append(ctx: *mut luw_ctx_t, src: *const u8) {