mirror of
https://github.com/arduino/Arduino.git
synced 2025-01-31 20:52:13 +01:00
Increase the redirect to follow to 20
Add the possibility to configure them `http.max_redirect_number`
This commit is contained in:
parent
58fc5a5011
commit
dde5668b27
@ -50,9 +50,11 @@ public class HttpConnectionManager {
|
|||||||
private static Logger log = LogManager.getLogger(HttpConnectionManager.class);
|
private static Logger log = LogManager.getLogger(HttpConnectionManager.class);
|
||||||
private static final String userAgent;
|
private static final String userAgent;
|
||||||
private static final int connectTimeout;
|
private static final int connectTimeout;
|
||||||
|
private static final int maxRedirectNumber;
|
||||||
private final URL requestURL;
|
private final URL requestURL;
|
||||||
private final String id;
|
private final String id;
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
final String defaultUserAgent = String.format(
|
final String defaultUserAgent = String.format(
|
||||||
"ArduinoIDE/%s (%s; %s; %s; %s) Java/%s (%s)",
|
"ArduinoIDE/%s (%s; %s; %s; %s) Java/%s (%s)",
|
||||||
@ -75,6 +77,17 @@ public class HttpConnectionManager {
|
|||||||
"Cannot parse the http.connection_timeout configuration switch to default {} milliseconds", connectTimeoutFromConfig, e.getCause());
|
"Cannot parse the http.connection_timeout configuration switch to default {} milliseconds", connectTimeoutFromConfig, e.getCause());
|
||||||
}
|
}
|
||||||
connectTimeout = connectTimeoutFromConfig;
|
connectTimeout = connectTimeoutFromConfig;
|
||||||
|
// Set by default 20 max redirect to follow
|
||||||
|
int maxRedirectNumberConfig = 20;
|
||||||
|
try {
|
||||||
|
maxRedirectNumberConfig =
|
||||||
|
Integer.parseInt(
|
||||||
|
PreferencesData.get("http.max_redirect_number", "20"));
|
||||||
|
} catch (NumberFormatException e) {
|
||||||
|
log.warn(
|
||||||
|
"Cannot parse the http.max_redirect_number configuration switch to default {}", maxRedirectNumberConfig, e.getCause());
|
||||||
|
}
|
||||||
|
maxRedirectNumber = maxRedirectNumberConfig;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HttpConnectionManager(URL requestURL) {
|
public HttpConnectionManager(URL requestURL) {
|
||||||
@ -102,7 +115,7 @@ public class HttpConnectionManager {
|
|||||||
|
|
||||||
private HttpURLConnection makeConnection(URL requestURL, int movedTimes,
|
private HttpURLConnection makeConnection(URL requestURL, int movedTimes,
|
||||||
Consumer<HttpURLConnection> beforeConnection) throws IOException, URISyntaxException, ScriptException, NoSuchMethodException {
|
Consumer<HttpURLConnection> beforeConnection) throws IOException, URISyntaxException, ScriptException, NoSuchMethodException {
|
||||||
if (movedTimes > 3) {
|
if (movedTimes > maxRedirectNumber) {
|
||||||
log.warn("Too many redirect " + requestURL);
|
log.warn("Too many redirect " + requestURL);
|
||||||
throw new IOException("Too many redirect " + requestURL);
|
throw new IOException("Too many redirect " + requestURL);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user