aboutsummaryrefslogtreecommitdiff
path: root/lib/std/http/Client.zig
diff options
context:
space:
mode:
authorAndrew Kelley <andrew@ziglang.org>2023-04-23 06:29:46 -0700
committerGitHub <noreply@github.com>2023-04-23 06:29:46 -0700
commit1884be4ecd2bf5458afedbc73eb3286a8b1b2d18 (patch)
tree27aa7f425b40a8f7b8e9392e19dec3c91d8b75a1 /lib/std/http/Client.zig
parentb95cdf0aeb4d4d31c0b6a54302ef61baec8f6773 (diff)
parentafebef2465a828132f87cd2aeff0c5873ca10de5 (diff)
downloadzig-1884be4ecd2bf5458afedbc73eb3286a8b1b2d18.tar.gz
zig-1884be4ecd2bf5458afedbc73eb3286a8b1b2d18.zip
Merge pull request #15372 from nwtgck/fix-http-client
Diffstat (limited to 'lib/std/http/Client.zig')
-rw-r--r--lib/std/http/Client.zig12
1 files changed, 6 insertions, 6 deletions
diff --git a/lib/std/http/Client.zig b/lib/std/http/Client.zig
index 4ff29a215a..3de15774d1 100644
--- a/lib/std/http/Client.zig
+++ b/lib/std/http/Client.zig
@@ -797,18 +797,18 @@ pub const Request = struct {
/// Write `bytes` to the server. The `transfer_encoding` request header determines how data will be sent.
pub fn write(req: *Request, bytes: []const u8) WriteError!usize {
- switch (req.headers.transfer_encoding) {
+ switch (req.transfer_encoding) {
.chunked => {
- try req.connection.data.conn.writer().print("{x}\r\n", .{bytes.len});
- try req.connection.data.conn.writeAll(bytes);
- try req.connection.data.conn.writeAll("\r\n");
+ try req.connection.data.buffered.writer().print("{x}\r\n", .{bytes.len});
+ try req.connection.data.buffered.writeAll(bytes);
+ try req.connection.data.buffered.writeAll("\r\n");
return bytes.len;
},
.content_length => |*len| {
if (len.* < bytes.len) return error.MessageTooLong;
- const amt = try req.connection.data.conn.write(bytes);
+ const amt = try req.connection.data.buffered.write(bytes);
len.* -= amt;
return amt;
},
@@ -828,7 +828,7 @@ pub const Request = struct {
/// Finish the body of a request. This notifies the server that you have no more data to send.
pub fn finish(req: *Request) FinishError!void {
switch (req.transfer_encoding) {
- .chunked => try req.connection.data.conn.writeAll("0\r\n\r\n"),
+ .chunked => try req.connection.data.buffered.writeAll("0\r\n\r\n"),
.content_length => |len| if (len != 0) return error.MessageNotCompleted,
.none => {},
}