public static <T> HttpResponseWriter streamingFrom(Stream<T> stream,
                                                       ResponseHeaders headers, HttpHeaders trailers,
                                                       Function<T, HttpData> contentConverter,
                                                       Executor executor) {
        requireNonNull(stream, "stream");
        requireNonNull(headers, "headers");
        requireNonNull(trailers, "trailers");
        requireNonNull(contentConverter, "contentConverter");
        requireNonNull(executor, "executor");

        final HttpResponseWriter writer = HttpResponse.streaming();
        executor.execute(() -> {
            try {
                final Iterator<T> it = stream.sequential().iterator();
                boolean headerSent = false;
                while (it.hasNext()) {
                    final HttpData content = contentConverter.apply(it.next());
                    if (!headerSent) {
                        writer.write(headers);
                        headerSent = true;
                    }
                    writer.write(content);
                }
                if (!trailers.isEmpty()) {
                    writer.write(trailers);
                }
                writer.close();
            } catch (Exception e) {
                writer.close(e);
            }
        });
        return writer;
    }
Returns a new {@link HttpResponseWriter} which sends a streaming response from the specified
{@link Stream}.

@param stream a sequence of objects
@param headers to be written to the returned {@link HttpResponseWriter}
@param trailers to be written to the returned {@link HttpResponseWriter}
@param contentConverter converts the published objects into streaming contents of the response
@param executor executes the iteration of the stream
core/src/main/java/com/linecorp/armeria/internal/server/ResponseConversionUtil.java