private int EncodeStatusCode(int statusCode, Span <byte> buffer) { switch (statusCode) { case 200: case 204: case 206: case 304: case 400: case 404: case 500: // TODO this isn't safe, some index can be larger than 64. Encoded here! buffer[0] = (byte)(0xC0 | H3StaticTable.StatusIndex[statusCode]); return(1); default: // Send as Literal Header Field Without Indexing - Indexed Name buffer[0] = 0x08; ReadOnlySpan <byte> statusBytes = StatusCodes.ToStatusBytes(statusCode); buffer[1] = (byte)statusBytes.Length; statusBytes.CopyTo(buffer.Slice(2)); return(2 + statusBytes.Length); } }