Skip to content

Commit

Permalink
Add extra helper
Browse files Browse the repository at this point in the history
  • Loading branch information
rubenlagus committed Apr 13, 2024
1 parent e9add4f commit d42ad30
Showing 1 changed file with 26 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ protected static OkHttpClient.Builder getBaseClient() {
}

@RequiredArgsConstructor
public static class ProxyOkHttpClientCreator extends DefaultOkHttpClientCreator {
public static class HttpProxyOkHttpClientCreator extends DefaultOkHttpClientCreator {
private final Supplier<Proxy> proxySupplier;
private final Supplier<Authenticator> authenticatorSupplier;

Expand All @@ -60,4 +60,29 @@ public OkHttpClient get() {
return okHttpClientBuilder.build();
}
}

@RequiredArgsConstructor
public static class SocksProxyOkHttpClientCreator extends DefaultOkHttpClientCreator {
private final Supplier<Proxy> proxySupplier;

@Override
public OkHttpClient get() {
OkHttpClient.Builder okHttpClientBuilder = getBaseClient();

// Proxy
ofNullable(proxySupplier.get()).ifPresent(okHttpClientBuilder::proxy);

return okHttpClientBuilder.build();
}
}

/**
* @deprecated Use {@link HttpProxyOkHttpClientCreator} instead
*/
@Deprecated
public static class ProxyOkHttpClientCreator extends HttpProxyOkHttpClientCreator {
public ProxyOkHttpClientCreator(Supplier<Proxy> proxySupplier, Supplier<Authenticator> authenticatorSupplier) {
super(proxySupplier, authenticatorSupplier);
}
}
}

0 comments on commit d42ad30

Please sign in to comment.