Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
public class HttpClient implements Call.Factory {
private final OkHttpClient ok;
HttpClient(final OkHttpClient ok) {
this.ok = ok;
}
/**
* Returns a CompletableCall, which supports CompletableFuture based enqueueing.
*/
public CompletableCall newCall(final Request request) {
return newCall(Ctx.fromThread().orElseGet(Ctx::empty), request);
}
/**
* Returns a CompletableCall, which supports CompletableFuture based enqueueing
*/
public CompletableCall newCall(Ctx ctx, final Request request) {
OkHttpClient.Builder b = this.ok.newBuilder();
b.interceptors().add(0, new CtxInterceptor(ctx));
return new CompletableCall(ctx, b.build().newCall(request));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.