1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 23:24:09 +00:00

zap: max_body_size, endpoint: mem buffer correction

This commit is contained in:
Rene Schallner 2023-01-19 21:49:02 +01:00
parent d258588454
commit 27f3cb8628
2 changed files with 5 additions and 3 deletions

View file

@ -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;

View file

@ -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,