From 9754c5b32b268a1869d3e54f81b0af87b1880390 Mon Sep 17 00:00:00 2001 From: Jarred Sumner <709451+Jarred-Sumner@users.noreply.github.com> Date: Mon, 19 Sep 2022 05:50:10 -0700 Subject: Fix larger bodies --- src/http_client_async.zig | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/http_client_async.zig b/src/http_client_async.zig index 567f92be6..3ba0c0b7c 100644 --- a/src/http_client_async.zig +++ b/src/http_client_async.zig @@ -1215,6 +1215,7 @@ pub fn onWritable(this: *HTTPClient, comptime is_first_call: bool, comptime is_s if (this.state.request_body.len > 0 and list.capacity - list.items.len > 0) { var remain = list.items.ptr[list.items.len..list.capacity]; const wrote = @minimum(remain.len, this.state.request_body.len); + std.debug.assert(wrote > 0); @memcpy(remain.ptr, this.state.request_body.ptr, wrote); list.items.len += wrote; } @@ -1254,6 +1255,11 @@ pub fn onWritable(this: *HTTPClient, comptime is_first_call: bool, comptime is_s if (has_sent_headers) { this.state.request_stage = .body; std.debug.assert(this.state.request_body.len > 0); + + // we sent everything, but there's some body leftover + if (amount == @intCast(c_int, to_send.len)) { + this.onWritable(false, is_ssl, socket); + } } else { this.state.request_stage = .headers; } -- cgit v1.2.3