errdefer posix.close(client_socket);
var event = linux.epoll_event{ .events = linux.EPOLL.IN, .data = .{ .fd = client_socket } };
try posix.epoll_ctl(self.efd, linux.EPOLL.CTL_ADD, client_socket, &event);
+ var addr: std.c.sockaddr = undefined;
+ var addr_size: std.c.socklen_t = @sizeOf(std.c.sockaddr);
+ _ = std.c.getpeername(client_socket, &addr, &addr_size);
+ std.debug.print("new connection from {}\n", .{addr});
} else {
var closed = false;
var req = Request{ .fd = ready_socket };
body: ?[]u8 = null,
pub fn parse(self: *Request, buf: []u8) bool {
+ std.debug.print("buf: {s}\n", .{buf});
var state: u8 = 0;
var start: u32 = 0;
}
}
- pub fn get_value(self: *Request, name: []const u8) ?[]const u8 {
+ pub fn get_value(self: Request, name: []const u8) ?[]const u8 {
const body = self.body orelse return null;
const name_index = std.mem.indexOf(u8, body, name) orelse return null;
const eql_index = std.mem.indexOfScalarPos(u8, body, name_index, '=') orelse return null;