Logs.debug("Download " + fullUrl + " to " + toFile.getAbsolutePath());
HttpRequest httpRequest = newHttpRequest(new URL(fullUrl));
if (!httpRequest.ok()) {
throw new IOException(MessageFormat.format(STATUS_RETURNED_BY_URL_IS_INVALID, fullUrl, httpRequest.code()));
}
httpRequest.receive(toFile);
} catch (Exception e) {
if (e.getCause() instanceof ConnectException || e.getCause() instanceof UnknownHostException) {
Logs.error(MessageFormat.format(SONAR_SERVER_CAN_NOT_BE_REACHED, serverUrl));
}