╭─────────────╮ │scroll to top│ ╰─────────────╯ ╭ serve_http.zig ───────────────────────────────────────────────╮ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ │ ╰───────────────────────────────────────────────────────────────╯
╭────╮ ╭ clone ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╮ │http│ ssh │ │ ╰────╯ ╰ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ─ ╯
280 } 281 return version; 282 } 283 284 fn findHeader(request: *std.http.Server.Request, name: []const u8) ?[]const u8 { 285 var it = request.iterateHeaders(); 286 while (it.next()) |header| { 287 if (std.ascii.eqlIgnoreCase(header.name, name)) return header.value; 288 } 289 return null; 290 } 291 292 fn writeSimpleResponse( 293 http_server: *std.http.Server, 294 code: u16, 295 message: []const u8, 296 content_type: []const u8, 297 body: []const u8, 298 ) !void { 299 try http_server.out.print( 300 "HTTP/1.1 {d} {s}\r\nContent-Type: {s}\r\nContent-Length: {d}\r\n\r\n{s}", 301 .{ code, message, content_type, body.len, body }, 302 ); 303 } 304