in elasticjob-cloud/elasticjob-cloud-scheduler/src/main/java/org/apache/shardingsphere/elasticjob/cloud/scheduler/util/HttpClientUtils.java [60:84]
public static HttpResult httpGet(final String url, final List<String> paramValues, final String encoding, final long readTimeoutMilliseconds) {
HttpURLConnection connection = null;
try {
String encodedContent = encodingParams(paramValues, encoding);
String urlWithParam = url + (null == encodedContent ? "" : ("?" + encodedContent));
connection = (HttpURLConnection) new URL(urlWithParam).openConnection();
connection.setRequestMethod("GET");
connection.setConnectTimeout((int) readTimeoutMilliseconds);
connection.setReadTimeout((int) readTimeoutMilliseconds);
connection.connect();
String response;
if (HttpURLConnection.HTTP_OK == connection.getResponseCode()) {
response = IOUtils.toString(connection.getInputStream(), encoding);
} else {
response = IOUtils.toString(connection.getErrorStream(), encoding);
}
return new HttpResult(connection.getResponseCode(), response);
} catch (final IOException ex) {
throw new HttpClientException(ex);
} finally {
if (null != connection) {
connection.disconnect();
}
}
}