org.xbib.helianthus.common.http.HttpResponse Maven / Gradle / Ivy
package org.xbib.helianthus.common.http;
import org.reactivestreams.Publisher;
import org.xbib.helianthus.common.Response;
import org.xbib.helianthus.common.stream.StreamMessage;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;
public interface HttpResponse extends Response, StreamMessage {
static HttpResponse of(Publisher extends HttpObject> publisher) {
return new PublisherBasedHttpResponse(publisher);
}
/**
* Aggregates the response. The returned {@link CompletableFuture} will be notified when the content and
* the trailing headers of the response are received fully.
*/
default CompletableFuture aggregate() {
final CompletableFuture future = new CompletableFuture<>();
subscribe(new HttpResponseAggregator(future));
return future;
}
@Override
CompletableFuture closeFuture();
/**
* Aggregates the response. The returned {@link CompletableFuture} will be notified when the content and
* the trailing headers of the response are received fully.
*/
default CompletableFuture aggregate(Executor executor) {
final CompletableFuture future = new CompletableFuture<>();
subscribe(new HttpResponseAggregator(future), executor);
return future;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy