With a status line and a header block in hand, today you assemble the whole response - status, headers, a blank line, then the body - into the exact bytes that go on the wire.
Serialize a Response of status, headers, and body into a complete HTTP response.
The two halves join into a Response and its serializer: status line, then
the header block, then a single blank line (\r\n), then the body bytes. That
blank line is the same delimiter you scanned for when reading a request — here you
are writing it.
Response is the counterpart to Request: handlers will return one, and the
connection loop will serialize it to the socket. Getting the byte layout exactly
right — CRLFs in the right places, one blank line before the body — is what makes
a browser accept your output as HTTP.
type Response struct {Status intHeaders map[string]stringBody []byte}// serialize: statusLine + headerBlock + "\r\n" + body