src/jdk.incubator.httpclient/share/classes/jdk/incubator/http/RequestPublishers.java
changeset 48408 4f830b447edf
parent 48379 5382baab8371
child 56008 bbd688c6fbbb
equal deleted inserted replaced
48407:fcb5b835bf32 48408:4f830b447edf
    44 import java.util.List;
    44 import java.util.List;
    45 import java.util.NoSuchElementException;
    45 import java.util.NoSuchElementException;
    46 import java.util.Objects;
    46 import java.util.Objects;
    47 import java.util.concurrent.ConcurrentLinkedQueue;
    47 import java.util.concurrent.ConcurrentLinkedQueue;
    48 import java.util.concurrent.Flow;
    48 import java.util.concurrent.Flow;
       
    49 import java.util.concurrent.Flow.Publisher;
    49 import java.util.function.Supplier;
    50 import java.util.function.Supplier;
    50 import jdk.incubator.http.HttpRequest.BodyPublisher;
    51 import jdk.incubator.http.HttpRequest.BodyPublisher;
    51 import jdk.incubator.http.internal.common.Utils;
    52 import jdk.incubator.http.internal.common.Utils;
    52 
    53 
    53 class RequestPublishers {
    54 class RequestPublishers {
   347         @Override
   348         @Override
   348         public long contentLength() {
   349         public long contentLength() {
   349             return -1;
   350             return -1;
   350         }
   351         }
   351     }
   352     }
       
   353 
       
   354     static final class PublisherAdapter implements BodyPublisher {
       
   355 
       
   356         private final Publisher<? extends ByteBuffer> publisher;
       
   357         private final long contentLength;
       
   358 
       
   359         PublisherAdapter(Publisher<? extends ByteBuffer> publisher,
       
   360                          long contentLength) {
       
   361             this.publisher = Objects.requireNonNull(publisher);
       
   362             this.contentLength = contentLength;
       
   363         }
       
   364 
       
   365         @Override
       
   366         public final long contentLength() {
       
   367             return contentLength;
       
   368         }
       
   369 
       
   370         @Override
       
   371         public final void subscribe(Flow.Subscriber<? super ByteBuffer> subscriber) {
       
   372             publisher.subscribe(subscriber);
       
   373         }
       
   374     }
   352 }
   375 }