< prev index next >

src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RequestPublishers.java

Print this page

        

*** 41,52 **** --- 41,54 ---- import java.util.ArrayList; import java.util.Collections; import java.util.Iterator; import java.util.List; import java.util.NoSuchElementException; + import java.util.Objects; import java.util.concurrent.ConcurrentLinkedQueue; import java.util.concurrent.Flow; + import java.util.concurrent.Flow.Publisher; import java.util.function.Supplier; import jdk.incubator.http.HttpRequest.BodyPublisher; import jdk.incubator.http.internal.common.Utils; class RequestPublishers {
*** 346,351 **** --- 348,375 ---- @Override public long contentLength() { return -1; } } + + static final class PublisherAdapter implements BodyPublisher { + + private final Publisher<? extends ByteBuffer> publisher; + private final long contentLength; + + PublisherAdapter(Publisher<? extends ByteBuffer> publisher, + long contentLength) { + this.publisher = Objects.requireNonNull(publisher); + this.contentLength = contentLength; + } + + @Override + public final long contentLength() { + return contentLength; + } + + @Override + public final void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) { + publisher.subscribe(subscriber); + } + } }
< prev index next >