╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve.zig ────────────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
507 while (it.next()) |header| { 508 if (std.ascii.eqlIgnoreCase(header.name, name)) return header.value; 509 } 510 return null; 511 } 512 513 fn writeSimpleResponse( 514 http_server: *std.http.Server, 515 code: u16, 516 message: []const u8, 517 content_type: []const u8, 518 body: []const u8, 519 ) !void { 520 try http_server.out.print( 521 "HTTP/1.1 {d} {s}\r\nContent-Type: {s}\r\nContent-Length: {d}\r\n\r\n{s}", 522 .{ code, message, content_type, body.len, body }, 523 ); 524 } 525 526 fn logError(err: *std.Io.Writer, comptime fmt: []const u8, args: anytype) void { 527 err.print(fmt, args) catch return; 528 err.flush() catch {}; 529 } 530