diff --git a/examples/endpoint/endpoint.zig b/examples/endpoint/endpoint.zig index 4648b68..d8a560d 100644 --- a/examples/endpoint/endpoint.zig +++ b/examples/endpoint/endpoint.zig @@ -75,8 +75,9 @@ fn listUsers(e: *zap.SimpleEndpoint, r: zap.SimpleRequest) void { var maybe_json: ?[]const u8 = null; var maybe_free: ?std.ArrayList(u8) = null; // if (users.count > 0) { - if (users.count > 20000) { - // if > 20000 users, 1MB might not be enough for json + if (users.count > 6000) { + // if > 6000 users, 1MB might not be enough for json + // ca 45 bytes of JSON overhead + 2 * 64 bytes of data if (zap.stringifyArrayListAlloc(alloc, User, &l, .{}) catch null) |string| { maybe_free = string; maybe_json = string.items; diff --git a/src/zap.zig b/src/zap.zig index 6e11bfe..0639b5a 100644 --- a/src/zap.zig +++ b/src/zap.zig @@ -125,6 +125,7 @@ pub const SimpleHttpListenerSettings = struct { on_request: ?SimpleHttpRequestFn, public_folder: ?[]const u8 = null, max_clients: ?isize = null, + max_body_size: ?usize = null, timeout: ?u8 = null, log: bool = false, }; @@ -173,7 +174,7 @@ pub const SimpleHttpListener = struct { .public_folder = pfolder, .public_folder_length = pfolder_len, .max_header_size = 32 * 1024, - .max_body_size = 50 * 1024 * 1024, + .max_body_size = self.settings.max_body_size orelse 50 * 1024 * 1024, .max_clients = self.settings.max_clients orelse 100, .tls = null, .reserved1 = 0,