Improved uptime survey in case of 403 status.

This commit is contained in:
Christian P. MOMON 2021-09-14 16:28:52 +02:00
parent 4ac7be0e78
commit abde4824f8

View file

@ -79,6 +79,7 @@ public class UptimeSurveyor
int boundMax = 7;
boolean ended = false;
URL currentURL = url;
String currentUserAgent = "StatoolInfos Uptime Bot";
result = 0;
int currentBound = 0;
while (!ended)
@ -88,7 +89,7 @@ public class UptimeSurveyor
HttpURLConnection connection = (HttpURLConnection) currentURL.openConnection();
connection.setConnectTimeout(5 * 1000);
connection.setReadTimeout(5 * 1000);
connection.setRequestProperty("User-Agent", "StatoolInfos Uptime Bot");
connection.setRequestProperty("User-Agent", currentUserAgent);
result = connection.getResponseCode();
String location = connection.getHeaderField("Location");
connection.disconnect();
@ -100,6 +101,13 @@ public class UptimeSurveyor
currentBound += 1;
}
else if (result == 403)
{
System.out.println(Thread.currentThread().getId() + " 403 FORBIDDEN DETECTED " + currentURL.toString() + " -> " + location);
currentUserAgent = "Mozilla from StatoolInfos Uptime B**";
currentBound += 1;
}
else
{
ended = true;