in src/main/java/org/apache/sling/servlethelpers/internalrequests/InternalRequest.java [224:243]
public InternalRequest checkStatus(int... acceptableValues) throws IOException {
assertRequestExecuted();
explicitStatusCheck = true;
if (acceptableValues == null || acceptableValues.length == 0) {
return this;
}
final int actualStatus = getStatus();
final OptionalInt found = Arrays.stream(acceptableValues)
.filter(expected -> expected == actualStatus)
.findFirst();
if (!found.isPresent()) {
final StringBuilder sb = new StringBuilder();
Arrays.stream(acceptableValues)
.forEach(val -> sb.append(sb.length() == 0 ? "" : ",").append(val));
throw new IOException("Unexpected response status " + actualStatus + ", expected one of '" + sb + "'");
}
return this;
}