All Downloads are FREE. Search and download functionalities are using the official Maven repository.

de.mklinger.qetcher.client.httpclient.internal.ByteArrayBodyProvider Maven / Gradle / Ivy

There is a newer version: 2.0.42.rc
Show newest version
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