code: protected HttpURLConnection createHttpURLConnection(final String url) throws IOException {
  
      URL sendUrl = new URL(url);
  
      HttpURLConnection con;
  
      if (StringUtils.isNotBlank(proxyHost) && proxyPort != null) {
  
        Proxy proxy = new Proxy(Proxy.Type.HTTP, new InetSocketAddress(proxyHost, proxyPort));
        con = (HttpURLConnection) sendUrl.openConnection(proxy);
        if (StringUtils.isNotBlank(proxyUsername)) {
          String passwd = proxyPassword != null ? proxyPassword : "";
          String authValue = proxyUsername + ":" + passwd;
          String headerValue = Base64.encodeBase64String(authValue.getBytes(
              StandardCharsets.UTF_8));
          con.setRequestProperty("Proxy-Authorization", "Basic " + headerValue);
        }
  
      } else {
  
        con = (HttpURLConnection) sendUrl.openConnection();
      }
  
      try {
        if (url.toLowerCase().startsWith("https")) {
          HttpsURLConnection secCon = (HttpsURLConnection) con;
          secCon.setHostnameVerifier(createAllHostnamesVerifier());
          SSLContext sc = SSLContext.getInstance("TLS");
          sc.init(null, createTrustAllManagers(), new SecureRandom());
          secCon.setSSLSocketFactory(sc.getSocketFactory());
        }
  
      } catch (NoSuchAlgorithmException | KeyManagementException e) {
        throw new IOException(e);
      }
  
      return con;
    }
docs: Creates the URL connection.
  
  @param url the URL
  @return the URL connection
  @throws IOException if creation of the URL connection fails