use of com.djrapitops.plan.exceptions.connection.ForbiddenException in project Plan by plan-player-analytics.
the class HttpsServerTest method testAccess.
default void testAccess(String address, String cookie) throws IOException, KeyManagementException, NoSuchAlgorithmException {
HttpURLConnection connection = null;
try {
connection = connector.getConnection("GET", address);
connection.setRequestProperty("Cookie", cookie);
int responseCode = connection.getResponseCode();
switch(responseCode) {
case 200:
case 302:
return;
case 400:
throw new BadRequestException("Bad Request: " + address);
case 403:
throw new ForbiddenException(address + " returned 403");
case 404:
throw new NotFoundException(address + " returned a 404, ensure that your server is connected to an up to date Plan server.");
case 500:
// Not supported
throw new IllegalStateException();
default:
throw new WebException(address + "| Wrong response code " + responseCode);
}
} finally {
connection.disconnect();
}
}
Aggregations