Panic `BADF` on a socket

I think you are running into the interface copying problem. See Zig 0.15.1 reader/writer: Don't make copies of @fieldParentPtr()-based interfaces for more conversation.

The short answer is to not copy the reader and writer from the stream.

var writer = conn.stream.writer(&output);
var reader = conn.stream.reader(&input);
var server = std.http.Server.init(reader.interface(), &writer.interface); 

To breakdown your issue, you wer copying the writer interface and then passing a pointer to that. This lost the parent fields required because it is now in a local variable that does not have the appopriate fields. The solution is to not capture the interface, but instead capture the parent field and pass a direct reference to the init function