de.mklinger.qetcher.client.httpclient.internal.ByteBufferBodyProvider Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qetcher-client-bundle Show documentation
Show all versions of qetcher-client-bundle Show documentation
Qetcher Java client, OSGi bundle, minimal dependencies
package de.mklinger.commons.httpclient.internal;
import java.nio.ByteBuffer;
import java.util.Collections;
import java.util.Iterator;
import java.util.concurrent.CompletableFuture;
import de.mklinger.commons.httpclient.HttpRequest;
/**
* @author Marc Klinger - mklinger[at]mklinger[dot]de
*/
public final class ByteBufferBodyProvider implements HttpRequest.BodyProvider {
private final long contentLength;
private final ByteBuffer byteBuffer;
public ByteBufferBodyProvider(final ByteBuffer byteBuffer) {
this.contentLength = byteBuffer.remaining();
this.byteBuffer = byteBuffer;
}
@Override
public Iterator> iterator() {
return Collections.singleton(
CompletableFuture.completedFuture(byteBuffer)
).iterator();
}
@Override
public long contentLength() {
return contentLength;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy