public static HttpStatus pingUrl(final String location) {
        try {
            val url = new URI(location).toURL();
            val connection = (HttpURLConnection) url.openConnection();
            connection.setConnectTimeout(PING_URL_TIMEOUT);
            connection.setReadTimeout(PING_URL_TIMEOUT);
            connection.setRequestMethod(HttpMethod.HEAD.name());
            return HttpStatus.valueOf(connection.getResponseCode());
        } catch (final Exception e) {
            LoggingUtils.error(LOGGER, e);
        }
        return HttpStatus.SERVICE_UNAVAILABLE;

    }
Ping url and return http status.

@param location the location
@return the http status
core/cas-server-core-util-api/src/main/java/org/apereo/cas/util/http/HttpRequestUtils.java