private static void download(@Nullable ProgressIndicator progress,
                               @NotNull String location,
                               @NotNull OutputStream output) throws IOException {
    String originalText = progress != null ? progress.getText() : null;
    substituteContentLength(progress, originalText, -1);
    if (progress != null) {
      progress.setText2(IdeCoreBundle.message("progress.download.0.title", location));
    }
    HttpRequests.request(location)
      .productNameAsUserAgent()
      .connect(new HttpRequests.RequestProcessor<>() {
        @Override
        public Object process(@NotNull HttpRequests.Request request) throws IOException {
          try {
            long contentLength = request.getConnection().getContentLengthLong();
            substituteContentLength(progress, originalText, contentLength);
            NetUtils.copyStreamContent(progress, request.getInputStream(), output, contentLength);
          }
          catch (IOException e) {
            throw new IOException(HttpRequests.createErrorMessage(e, request, true), e);
          }
          return null;
        }
      });
  }
private static void download(@Nullable ProgressIndicator progress,
                               @NotNull String location,
                               @NotNull OutputStream output)