de.mklinger.qetcher.client.httpclient.internal.ByteArrayBodyProvider 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 ByteArrayBodyProvider implements HttpRequest.BodyProvider {
private final byte[] b;
public ByteArrayBodyProvider(final byte[] b) {
this.b = b;
}
@Override
public Iterator> iterator() {
return Collections.singleton(
CompletableFuture.completedFuture(ByteBuffer.wrap(b))
).iterator();
}
@Override
public long contentLength() {
return b.length;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy