╭ changed ─────────╮ │src/serve_http.zig│ ╰──────────────────╯ ╭───────────╮ │← all files│ ╰───────────╯ ╭──────────────────────────────────────────────────────────────────────────────────────────────╮ │56 var conn_bw = stream.writer(io, &send_buffer); │ │57 var http_server = std.http.Server.init(&conn_br.interface, &conn_bw.interface); │ │58 │ │59 - while (http_server.reader.state == .ready) { │ │59 + if (http_server.reader.state == .ready) { │ │60 var request = http_server.receiveHead() catch |receive_err| switch (receive_err) {│ │61 - error.HttpConnectionClosing => break, │ │62 - error.ReadFailed => break, │ │61 + error.HttpConnectionClosing => return, │ │62 + error.ReadFailed => return, │ │63 else => |e| return e, │ │64 }; │ │65 │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮ │72 try writeSimpleResponse(&http_server, 500, "Internal Server Error", "text/plain", @errorName(request_err));│ │73 }; │ │74 try http_server.out.flush(); │ │75 - break; │ │75 } │ │76 } │ │77 │ ╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭───────────────────────────────────────────────────────────────────────────────────────────────╮ │147 .protocol_version = protocol_version, │ │148 }; │ │149 │ │151 - try openRepoAndServe(repo_kind, any_repo_opts, io, allocator, repo_path, GitService{ │ │150 + // serve the existing on-disk repo at its event-id directory; HTTP only │ │151 + // handles fetch/clone, so a missing repo is simply not found │ │152 + if (!try serveIfExists(repo_kind, any_repo_opts, io, allocator, repo_path, GitService{│ │153 .body_reader = &body_reader, │ │154 .writer = http_server.out, │ │155 .options = http_backend_options, │ ╰───────────────────────────────────────────────────────────────────────────────────────────────╯ ╭─────────────────────────────────────────────────────────────────────────────────────────────────────╮ │155 - }); │ │156 + })) return error.RepoNotFound; │ │157 } │ │158 │ │159 fn findRoute(path: []const u8) ?struct { xit.net_server_http_backend.HandlerKind, []const u8 } {│ ╰─────────────────────────────────────────────────────────────────────────────────────────────────────╯ ╭────────────────────────────────────────────────────────────────────────────────────────────────────╮ │165 return null; │ │166 } │ │167 │ │167 -fn openRepoAndServe( │ │168 - comptime repo_kind: rp.RepoKind, │ │169 - comptime any_repo_opts: rp.AnyRepoOpts(repo_kind), │ │170 - io: std.Io, │ │171 - allocator: std.mem.Allocator, │ │172 - repo_path: []const u8, │ │173 - service: anytype, │ │174 -) !void { │ │175 - // serve the existing on-disk repo at its event-id directory; HTTP only │ │176 - // handles fetch/clone, so a missing repo is simply not found │ │177 - if (try serveIfExists(repo_kind, any_repo_opts, io, allocator, repo_path, service)) return;│ │178 - return error.RepoNotFound; │ │179 -} │ │180 - │ │168 // serve an existing repo at `repo_path`, or return false if none is there │ │169 fn serveIfExists( │ │170 comptime repo_kind: rp.RepoKind, │ ╰────────────────────────────────────────────────────────────────────────────────────────────────────╯