From abde4824f8fece1f6e53399af3b99b0cbfcb5a9e Mon Sep 17 00:00:00 2001 From: "Christian P. MOMON" Date: Tue, 14 Sep 2021 16:28:52 +0200 Subject: [PATCH] Improved uptime survey in case of 403 status. --- src/fr/devinsy/statoolinfos/uptime/UptimeSurveyor.java | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/fr/devinsy/statoolinfos/uptime/UptimeSurveyor.java b/src/fr/devinsy/statoolinfos/uptime/UptimeSurveyor.java index a10806a..96f8c9f 100644 --- a/src/fr/devinsy/statoolinfos/uptime/UptimeSurveyor.java +++ b/src/fr/devinsy/statoolinfos/uptime/UptimeSurveyor.java @@ -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;