protected synchronized boolean download(final DownloadableFile downloadableFile) throws IOException, GeneralSecurityException {
        File toDownload = downloadableFile.getLocalFile();
        LOG.info("Downloading {}", toDownload);
        String url = downloadableFile.url(urlGenerator);
        final HttpRequestBase request = new HttpGet(url);
        request.setConfig(RequestConfig.custom().setConnectTimeout(HTTP_TIMEOUT_IN_MILLISECONDS).build());

        try (CloseableHttpClient httpClient = httpClientBuilder.build();
             CloseableHttpResponse response = httpClient.execute(request)) {
            LOG.info("Got server response");
            if (response.getEntity() == null) {
                LOG.error("Unable to read file from the server response");
                return false;
            }
            handleInvalidResponse(response, url);
            try (BufferedOutputStream outStream = new BufferedOutputStream(new FileOutputStream(downloadableFile.getLocalFile()))) {
                response.getEntity().writeTo(outStream);
                LOG.info("Piped the stream to {}", downloadableFile);
            }
        }
        return true;
    }
@Test
    public void shouldThrowExceptionIfTheServerIsDown() {
        ServerBinaryDownloader downloader = new ServerBinaryDownloader(new GoAgentServerHttpClientBuilder(null, SslVerificationMode.NONE, null, null, null), ServerUrlGeneratorMother.generatorFor("locahost", server.getPort()));
        assertThatThrownBy(() -> downloader.download(DownloadableFile.AGENT))
                .isExactlyInstanceOf(UnknownHostException.class);
    }