╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve_http.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─╯
273 while (it.next()) |header| { 274 if (std.ascii.eqlIgnoreCase(header.name, name)) return header.value; 275 } 276 return null; 277 } 278 279 fn writeSimpleResponse( 280 http_server: *std.http.Server, 281 code: u16, 282 message: []const u8, 283 content_type: []const u8, 284 body: []const u8, 285 ) !void { 286 try http_server.out.print( 287 "HTTP/1.1 {d} {s}\r\nContent-Type: {s}\r\nContent-Length: {d}\r\n\r\n{s}", 288 .{ code, message, content_type, body.len, body }, 289 ); 290 } 291