private static HttpData toHttpData(ServerSentEvent sse) {
        final StringBuilder sb = new StringBuilder();

        // Write a comment first because a user might want to explain his or her event at first line.
        final String comment = sse.comment();
        if (comment != null) {
            appendField(sb, "", comment, false);
        }

        final String id = sse.id();
        if (id != null) {
            appendField(sb, "id", id, true);
        }

        final String event = sse.event();
        if (event != null) {
            appendField(sb, "event", event, true);
        }

        final String data = sse.data();
        if (data != null) {
            appendField(sb, "data", data, true);
        }

        final Duration retry = sse.retry();
        if (retry != null) {
            // Reconnection time, in milliseconds.
            sb.append("retry:").append(retry.toMillis()).append(LINE_FEED);
        }

        return sb.length() == 0 ? HttpData.empty()
                                : HttpData.ofUtf8(sb.append(LINE_FEED).toString());
    }
Creates a new Server-Sent Events stream of the specified {@code content}.

@param headers the HTTP headers supposed to send
@param sse the {@link ServerSentEvent} object supposed to send as contents
@param trailers the HTTP trailers
core/src/main/java/com/linecorp/armeria/server/streaming/ServerSentEvents.java