Hello,
I’m not able to make an HTTPS POST request with Zig 0.15.1 using the following code.
When I run this code, I get the error: HttpConnectionClosing
.
I found this issue: std.http.Client blocks forever with larger payloads on HTTPS requests · Issue #25015 · ziglang/zig · GitHub
However, that report is about large payloads, while I’m experiencing the same issue even with small payloads (using the same code).
Do you have any idea what might be causing this?
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 = "Hello World",
.response_writer = &allocating.writer,
};
var client: Client = .{ .allocator = alloc };
defer client.deinit();
_ = try client.fetch(opts);
std.debug.print("{s}\n", .{allocating.written()});
}