use of com.couchbase.client.core.error.HttpStatusCodeException in project couchbase-jvm-clients by couchbase.
the class AsyncCouchbaseHttpClient method exec.
private CompletableFuture<HttpResponse> exec(HttpMethod method, HttpTarget target, HttpPath path, CommonHttpOptions<?>.BuiltCommonHttpOptions options, Consumer<CoreHttpRequest.Builder> customizer) {
CoreHttpRequest.Builder builder = new CoreHttpClient(core, target.coreTarget).newRequest(method, CoreHttpPath.path(path.formatted), options).bypassExceptionTranslation(true);
options.headers().forEach(it -> builder.header(it.name, it.value));
customizer.accept(builder);
CoreHttpRequest req = builder.build();
// request doesn't mysteriously time out while the service locator twiddles its thumbs.
if (req.bucket() != null) {
cluster.bucket(req.bucket());
}
return req.exec(core).thenApply(HttpResponse::new).exceptionally(t -> {
HttpStatusCodeException statusCodeException = findCause(t, HttpStatusCodeException.class).orElseThrow(() -> propagate(t));
return new HttpResponse(statusCodeException);
});
}
Aggregations