-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.
Milestone
Description
Zig Version
0.16.0-dev.27+83f773fc6
Steps to Reproduce and Observed Behavior
Large payloads for std.http.Client.fetch seem to block forever under HTTPS connections. Increasing write_buffer_size
in http.Client workarounds it.
How to reproduce:
const std = @import("std");
const Client = std.http.Client;
pub fn main() !void {
const alloc = std.heap.page_allocator;
var allocating = std.Io.Writer.Allocating.init(alloc);
defer allocating.deinit();
const opts: Client.FetchOptions = .{
.method = .POST,
.location = .{ .url = "https://httpbin.org/post" },
.payload = "631df10a8621493a1f71ce5e068583395846480e0f127f1c9ab46f6cbad83829" ** 64,
.response_writer = &allocating.writer,
};
var client: Client = .{ .allocator = alloc };
defer client.deinit();
_ = try client.fetch(opts);
std.debug.print("{s}\n", .{allocating.written()});
}
Workaround by increasing write_buffer_size
:
const std = @import("std");
const Client = std.http.Client;
pub fn main() !void {
const alloc = std.heap.page_allocator;
var allocating = std.Io.Writer.Allocating.init(alloc);
defer allocating.deinit();
const opts: Client.FetchOptions = .{
.method = .POST,
.location = .{ .url = "https://httpbin.org/post" },
.payload = "631df10a8621493a1f71ce5e068583395846480e0f127f1c9ab46f6cbad83829" ** 64,
.response_writer = &allocating.writer,
};
var client: Client = .{ .allocator = alloc, .write_buffer_size = 8192 };
defer client.deinit();
_ = try client.fetch(opts);
std.debug.print("{s}\n", .{allocating.written()});
}
Changing url to http:// instead of https:// works as well.
Expected Behavior
The post request gets sent without blocking forever and without requiring increasing the write_buffer_size.
tranzystorekk, tensorush, maxmilton, vak0160 and g-cassie
Metadata
Metadata
Assignees
Labels
bugObserved behavior contradicts documented or intended behaviorObserved behavior contradicts documented or intended behaviorstandard libraryThis issue involves writing Zig code for the standard library.This issue involves writing Zig code for the standard library.