Zig
Zig
Setting a HTTP Max Response Size
Demonstrates theMaxResponseSize property.
Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
const http = try chilkat.Http.init();
defer http.deinit();
const max_sz = 16384;
http.setMaxResponseSize(max_sz);
// Try to get something larger, such as hamlet.xml which is 279658 bytes
_ = http.quickGetStr(alloc, "https://chilkatsoft.com/hamlet.xml") catch {
// If the LastErrorText contains the string "MaxResponseSize",
// then the HTTP request failed because the response body would've been larger than the max allowed response size.
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
std.debug.print("OK\n", .{});
}