Commit 3d75311
committed
server: restore HTTP API — migrate to std.Io.net + std.http.Server v2
From fleet code review 2026-06-01 (`incomplete-undefined`, CRITICAL).
`codescan serve` had been returning `error.HttpServerNotMigrated` ever
since the Zig 0.15→0.16 port; the placeholder commit added a graceful
stderr message but the server was still dead.
This commit replaces the placeholder with a real listen-accept-dispatch
loop:
- `address.listen(io, .{ .reuse_address = true })` per the 0.16
`std.Io.net.IpAddress` API; deferred close of the listening socket
- accept loop with logged-and-continue on per-connection errors
(so a malformed request doesn't kill the server)
- per-connection 16 KB header + 16 KB write buffer (enough for typical
requests; clients sending oversized heads get
`error.HttpHeadersOversize`)
- `std.http.Server.init(&reader.interface, &writer.interface)` for the
v2 io-aware HTTP frontend
- `receiveHead` → existing `handleRequest(allocator, &req, db,
embedder, settings)` (which was already written against the v2
Request API)
- handler errors logged with the request target; best-effort 500
response if nothing was sent yet
Smoke-tested end-to-end against the codescan repo's own index:
GET /health → 200 `{"status":"ok"}`
GET /status → 200 (full index JSON: 101 files, 6402 symbols)
GET /help → 200 (API docs)
POST /search → 200 (lexical hits, correct ranking)
PLAN.md: both HTTP server items checked off (Phase 4 + Phase 5b).
All 51 test binaries still pass.1 parent 23f8d44 commit 3d75311
2 files changed
Lines changed: 70 additions & 19 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
35 | | - | |
| 35 | + | |
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
| 143 | + | |
144 | 144 | | |
145 | 145 | | |
146 | 146 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
90 | 95 | | |
91 | | - | |
92 | | - | |
93 | | - | |
94 | | - | |
95 | | - | |
96 | | - | |
97 | | - | |
98 | | - | |
99 | | - | |
100 | | - | |
101 | | - | |
102 | | - | |
103 | | - | |
104 | | - | |
105 | | - | |
106 | | - | |
107 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
108 | 159 | | |
109 | 160 | | |
110 | 161 | | |
| |||
0 commit comments