private static StreamWriter<StreamMessage<HttpData>> newEmitter(Subscription upstream) {
        final StreamWriter<StreamMessage<HttpData>> emitter =
                new DefaultStreamMessage<StreamMessage<HttpData>>() {
                    @Override
                    protected void onRequest(long n) {
                        // A BodyPart is converted to a StreamMessage<HttpData> one to one.
                        upstream.request(n);
                    }
                };
        emitter.whenComplete().handle((unused, cause) -> {
            if (cause instanceof CancelledSubscriptionException) {
                upstream.cancel();
            }
            return null;
        });
        return emitter;
    }
Reactive processor that encodes a stream of {@link BodyPart}s into an HTTP payload.
core/src/main/java/com/linecorp/armeria/common/multipart/MultipartEncoder.java