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