public static String requestURL(String urlToRead) {
    String result = "";
    BufferedReader rd;
    String line = null;
    String url = urlToRead;

    try {
      URLStreamProvider urlStreamProvider = new URLStreamProvider(ProxyService.URL_CONNECT_TIMEOUT,
          ProxyService.URL_READ_TIMEOUT, ComponentSSLConfiguration.instance());

      Map<String, List<String>> headers = new HashMap<>();

      HttpURLConnection connection = urlStreamProvider.processURL(url, "GET", (String) null, headers);

      int responseCode = connection.getResponseCode();
      InputStream resultInputStream = null;
      if (responseCode >= ProxyService.HTTP_ERROR_RANGE_START) {
        resultInputStream = connection.getErrorStream();
      } else {
        resultInputStream = connection.getInputStream();
      }

      rd = new BufferedReader(new InputStreamReader(resultInputStream));

      line = rd.readLine();
      while (line != null) {
        result += line;
        line = rd.readLine();
      }
      rd.close();
    } catch (Exception e) {
      e.printStackTrace();
    }
    return result;
  }
Issues a GET request against a URL.
@param urlToRead URL to read from
@return Returns a response string if successful, and empty otherwise.
ambari-server/src/main/java/org/apache/ambari/server/utils/HTTPUtils.java