authorgravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-05-05 17:25:42-07:00
committergravatar for andrew@ziglang.orgAndrew Kelley <andrew@ziglang.org> 2025-07-01 16:35:28-07:00
logb3df9d4bf91e4df6a643ab23c8ec44f239cd14b6
treeef43932d25b62bc20ae04d0b0223de2740cd1538
parentd0b839285285c53da93dad0c81150dbdc18ead40

std.http.Client: sendBody flush by default; fix flushing

flushing must also flush TLS client if it exists

1 files changed, 15 insertions(+), 2 deletions(-)

lib/std/http/Client.zig+15-2
...@@ -820,7 +820,7 @@ pub const Request = struct {...@@ -820,7 +820,7 @@ pub const Request = struct {
820 /// Sends and flushes a complete request as only HTTP head, no body.820 /// Sends and flushes a complete request as only HTTP head, no body.
821 pub fn sendBodiless(r: *Request) std.io.Writer.Error!void {821 pub fn sendBodiless(r: *Request) std.io.Writer.Error!void {
822 try sendBodilessUnflushed(r);822 try sendBodilessUnflushed(r);
823 try r.connection.?.writer.flush();823 try r.connection.?.flush();
824 }824 }
825825
826 /// Sends but does not flush a complete request as only HTTP head, no body.826 /// Sends but does not flush a complete request as only HTTP head, no body.
...@@ -830,9 +830,22 @@ pub const Request = struct {...@@ -830,9 +830,22 @@ pub const Request = struct {
830 try sendHead(r);830 try sendHead(r);
831 }831 }
832832
833 /// Transfers the HTTP head over the connection and flushes.
834 ///
835 /// See also:
836 /// * `sendBodyUnflushed`
837 pub fn sendBody(r: *Request) std.io.Writer.Error!http.BodyWriter {
838 const result = try sendBodyUnflushed(r);
839 try r.connection.?.flush();
840 return result;
841 }
842
833 /// Transfers the HTTP head over the connection, which is not flushed until843 /// Transfers the HTTP head over the connection, which is not flushed until
834 /// `BodyWriter.flush` or `BodyWriter.end` is called.844 /// `BodyWriter.flush` or `BodyWriter.end` is called.
835 pub fn sendBody(r: *Request) std.io.Writer.Error!http.BodyWriter {845 ///
846 /// See also:
847 /// * `sendBody`
848 pub fn sendBodyUnflushed(r: *Request) std.io.Writer.Error!http.BodyWriter {
836 assert(r.method.requestHasBody());849 assert(r.method.requestHasBody());
837 try sendHead(r);850 try sendHead(r);
838 return .{851 return .{