private @NotNull File downloadFile(final @NotNull DownloadableFileUrl description, final @NotNull File existingFile, int expectedDownloads) throws IOException {
    final String presentableUrl = description.getPresentableDownloadUrl();
    Map<String, String> headers = JpsServerAuthUtil.getRequestHeaders();

    try (CloseableHttpClient client = HttpClientBuilder.create().disableAutomaticRetries().build()) {
      HttpGet httpRequest = new HttpGet(description.getDownloadUrl());
      headers.forEach((k, v) -> httpRequest.setHeader(k, v));
      HttpResponse response = client.execute(httpRequest);
      HttpEntity responseEntity = response.getEntity();
      if (response.getStatusLine().getStatusCode() == 200) {
        long size = responseEntity.getContentLength();
        if (existingFile.exists() && size == existingFile.length()) {
          return existingFile;
        }

        Header header = response.getFirstHeader(CDN_CACHE_HEADER);
        if (header != null && header.getValue().startsWith("Hit")) hitsCount++;

        myNettyClient.sendDescriptionStatusMessage(JpsBuildBundle.message("progress.download.file.text", description.getPresentableFileName(), presentableUrl), expectedDownloads);
        return saveToFile(FileUtil.createTempFile("download.", ".tmp").toPath(), responseEntity, myContext).toFile();
      }
      else {
        String errorText = StreamUtil.readText(new InputStreamReader(responseEntity.getContent(), StandardCharsets.UTF_8));
        throw new IOException("Request: " + description.getDownloadUrl() + " Error: " + response.getStatusLine().getStatusCode() + " body: " + errorText);
      }
    }
  }
private @NotNull File downloadFile(final @NotNull DownloadableFileUrl description, final @NotNull File existingFile, int expectedDownloads)