aboutsummaryrefslogtreecommitdiff
path: root/lib/std/debug.zig
diff options
context:
space:
mode:
authorNameless <truemedian@gmail.com>2023-03-13 12:46:58 -0500
committerNameless <truemedian@gmail.com>2023-04-08 09:59:35 -0500
commit08bdaf3bd650ec7682f1424c3644fc3b762ccf27 (patch)
tree733f2b571bfbe39c3c78d1548a27c5bc7104476c /lib/std/debug.zig
parentfde05b10b3c29b914e4d2ef034dcd8a78800ef6e (diff)
downloadzig-08bdaf3bd650ec7682f1424c3644fc3b762ccf27.tar.gz
zig-08bdaf3bd650ec7682f1424c3644fc3b762ccf27.zip
std.http: add http server
* extract http protocol into protocol.zig, as it is shared between client and server * coalesce Request and Response back into Client.zig, they don't contain any large chunks of code anymore * http.Server is implemented as basic as possible, a simple example below: ```zig fn handler(res: *Server.Response) !void { while (true) { defer res.reset(); try res.waitForCompleteHead(); res.headers.transfer_encoding = .{ .content_length = 14 }; res.headers.connection = res.request.headers.connection; try res.sendResponseHead(); _ = try res.write("Hello, World!\n"); if (res.connection.closing) break; } } pub fn main() !void { var server = Server.init(std.heap.page_allocator, .{ .reuse_address = true }); defer server.deinit(); try server.listen(try net.Address.parseIp("127.0.0.1", 8080)); while (true) { const res = try server.accept(.{ .dynamic = 8192 }); const thread = try std.Thread.spawn(.{}, handler, .{res}); thread.detach(); } } ```
Diffstat (limited to 'lib/std/debug.zig')
0 files changed, 0 insertions, 0 deletions