2
0
Fork 0
mirror of https://github.com/ethauvin/bld.git synced 2025-04-25 00:07:12 -07:00

Updated core submodule. Ensure user agent is set for URL connections in artifact retriever.

This commit is contained in:
Geert Bevin 2023-05-11 08:05:45 -04:00
parent c213e3df7d
commit eca0a3cb9c
2 changed files with 11 additions and 6 deletions

2
core

@ -1 +1 @@
Subproject commit 9f6e40afa519ab922cc431d8da7e812ee9b60d7a
Subproject commit d4e67afb8bb538c33c3550ecabb33c22ca3ee6b7

View file

@ -13,6 +13,7 @@ import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.net.URL;
import java.net.URLConnection;
import java.nio.channels.Channels;
import java.security.MessageDigest;
import java.util.*;
@ -99,9 +100,7 @@ public abstract class ArtifactRetriever {
}
try {
var connection = new URL(artifact.location()).openConnection();
connection.setUseCaches(false);
connection.setRequestProperty("User-Agent", "bld " + BldVersion.getVersion());
var connection = openUrlConnection(artifact);
if (artifact.repository().username() != null && artifact.repository().password() != null) {
connection.setRequestProperty(
HEADER_AUTHORIZATION,
@ -163,8 +162,7 @@ public abstract class ArtifactRetriever {
}
}
var connection = new URL(artifact.location()).openConnection();
connection.setUseCaches(false);
var connection = openUrlConnection(artifact);
if (artifact.repository().username() != null && artifact.repository().password() != null) {
connection.setRequestProperty(
HEADER_AUTHORIZATION,
@ -190,6 +188,13 @@ public abstract class ArtifactRetriever {
}
}
private static URLConnection openUrlConnection(RepositoryArtifact artifact) throws IOException {
var connection = new URL(artifact.location()).openConnection();
connection.setUseCaches(false);
connection.setRequestProperty("User-Agent", "bld " + BldVersion.getVersion());
return connection;
}
private boolean checkHash(RepositoryArtifact artifact, File downloadFile, String extension, String algorithm) {
try {
var hash_sum = readString(artifact.appendPath(extension));