1
0
Fork 0
mirror of https://github.com/zigzap/zap.git synced 2025-10-20 15:14:08 +00:00
zap/wrk/zigstd/main.zig
Rene Schallner d0c59ab008 fixed AuthEndpoint callbacks, BasicAuth logging
AuthEndpoint callbacks now provide pointers to the original
SimpleEndpoint structs, so their fieldParentPtr calls work.
Added extensive debug() logging to BasicAuth with .UserPassword.
2023-05-01 05:55:08 +02:00

34 lines
1.1 KiB
Zig

const std = @import("std");
pub fn main() !void {
const allocator = std.heap.page_allocator;
var server = std.http.Server.init(allocator, .{
.reuse_address = true,
});
defer server.deinit();
const address = try std.net.Address.parseIp("127.0.0.1", 3000);
try server.listen(address);
const max_header_size = 8192;
while (true) {
var res = try server.accept(.{ .dynamic = max_header_size });
const start_time = std.time.nanoTimestamp();
defer res.deinit();
defer res.reset();
try res.wait();
const server_body: []const u8 = "HI FROM ZIG STD!\n";
res.transfer_encoding = .{ .content_length = server_body.len };
try res.headers.append("content-type", "text/plain");
try res.headers.append("connection", "close");
try res.do();
var buf: [128]u8 = undefined;
_ = try res.readAll(&buf);
_ = try res.writer().writeAll(server_body);
try res.finish();
const end_time = std.time.nanoTimestamp();
const diff = end_time - start_time;
std.debug.print("{d}\n", .{diff});
}
}