private static void download(final String targetUrlString, final Path path, final String userAgent) throws IOException {
        logger.info("Started download from: " + targetUrlString);

        String urlString = targetUrlString;
        for (int i = 0; i < MAXIMUM_REDIRECTS; ++i) {
            final Optional<String> nextUrlString = getDownloadedOrNextUrl(urlString, path, userAgent);
            if (!nextUrlString.isPresent()) {
                return;
            }
            logger.info("Redirected to: " + nextUrlString.get());
            urlString = nextUrlString.get();
        }
        throw new IOException("Too many redirects from: " + targetUrlString);
    }
Runs the selfupdate subcommand of Embulk.

<p>It uses {@link java.net.HttpURLConnection} so that CLI classes do not need additional dependedcies.

<p>TODO: Support HTTP(S) proxy. The original Ruby version did not support as well, though.
embulk-core/src/main/java/org/embulk/cli/SelfUpdate.java