private static HttpURLConnection handleRedirects(HttpURLConnection httpConn, ConnectionConfigurator configurator)
			throws IOException {
		int responseCode;
		int redirects = 0;
		while (true) {
			httpConn.setInstanceFollowRedirects(false);
			responseCode = httpConn.getResponseCode();
			if (responseCode == HttpURLConnection.HTTP_MULT_CHOICE ||
					responseCode == HttpURLConnection.HTTP_MOVED_PERM ||
					responseCode == HttpURLConnection.HTTP_MOVED_TEMP ||
					responseCode == HttpURLConnection.HTTP_SEE_OTHER ||
					responseCode == 307 /* TEMP REDIRECT */ ||
					responseCode == 308 /* PERM REDIRECT */) {
				if (redirects++ > 8) {
					throw new IOException("Too many redirects");
				}
				String location = httpConn.getHeaderField("Location");
				if (location == null) {
					throw new IOException("No 'Location' header in redirect");
				}
				URL url = new URL(httpConn.getURL(), location);
				url = new URL(swizzleURL(url.toString()));
				verboseMsg("Redirected to: " + url); // Should be debug info
				httpConn = (HttpURLConnection) url.openConnection();
				if (responseCode == HttpURLConnection.HTTP_SEE_OTHER) {
					// This response code forces the method to GET
					httpConn.setRequestMethod("GET");
				}
				configurator.configure(httpConn);
				continue;
			}
			break;
		}
		return httpConn;
	}
Downloads a file from a URL

@param fileURL HTTP URL of the file to be downloaded
@param saveDir path of the directory to save the file
@param timeOut the timeout in milliseconds to use for opening the connection.
               0 is an infinite timeout while -1 uses the defaults
@return Path to the downloaded file
@throws IOException
src/main/java/dev/jbang/util/Util.java