use of it.spid.cie.oidc.exception.EntityException in project spid-cie-oidc-java by italia.
the class EntityHelper method doHttpGet.
/**
* @param url
* @return
* @throws OIDCException
*/
private static String doHttpGet(String url) throws OIDCException {
try {
HttpRequest request = HttpRequest.newBuilder().uri(new URI(url)).GET().build();
HttpResponse<String> response = HttpClient.newBuilder().followRedirects(HttpClient.Redirect.NORMAL).build().send(request, BodyHandlers.ofString());
if (logger.isDebugEnabled()) {
logger.debug(url + " --> " + response.statusCode());
}
if (response.statusCode() != 200) {
throw new EntityException.Generic(url + " gets " + response.statusCode());
}
return response.body();
} catch (EntityException e) {
throw e;
} catch (Exception e) {
throw new EntityException.Generic(e);
}
}
Aggregations