public Integer handleResponse()

in src/main/java/org/apache/sling/maven/bundlesupport/deploy/method/ResponseCodeEnforcingResponseHandler.java [65:90]


    public Integer handleResponse(ClassicHttpResponse response) throws HttpException, IOException {
        final HttpEntity entity = response.getEntity();
        try {
            if (responseStringPredicate != null) {
                String responseContent = EntityUtils.toString(entity);
                if (!responseStringPredicate.test(responseContent)) {
                    throw new ClientProtocolException("Unexpected response content returned: " + responseContent);
                }
            }
            if (!allowedCodes.contains(response.getCode())) {
                throw new HttpResponseException(
                        response.getCode(),
                        "Unexpected response code " + response.getCode() + ": " + response.getReasonPhrase());
            }
            String actualContentType = Optional.ofNullable(response.getHeader(HttpHeaders.CONTENT_TYPE))
                    .map(Header::getValue)
                    .orElse(null);
            if (expectedContentType != null && expectedContentType.equals(actualContentType)) {
                throw new ClientProtocolException("Unexpected content type returned, expected " + expectedContentType
                        + " but was " + actualContentType);
            }
        } finally {
            EntityUtils.consume(entity);
        }
        return response.getCode();
    }