import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
+import java.net.Proxy;
+import java.net.ProxySelector;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.charset.StandardCharsets;
import java.util.HashMap;
throw new IOException(throwableOptional);
}
}
- return response.successOrThrow();
+ try {
+ return response.successOrThrow();
+ } catch (Throwable e) {
+ throw new AssertionError(e);
+ }
}
public static ByteString firstNonEmpty(ByteString... strings) {
public static String nullIfEmpty(String string) {
return string == null || string.isEmpty() ? null : string;
}
+
+ public static Proxy getHttpsProxy() {
+ final URI uri;
+ try {
+ uri = new URI("https://example");
+ } catch (URISyntaxException e) {
+ throw new RuntimeException(e);
+ }
+ final var proxies = ProxySelector.getDefault().select(uri);
+ if (proxies.isEmpty()) {
+ return Proxy.NO_PROXY;
+ } else {
+ return proxies.getFirst();
+ }
+ }
}